Reputation: 9828
Is it possible to bind (one-way and two way) an angular object but using a dynamic string.
So instead of doing
{{ myObject.name }}
I can do this, which works fine
{{ myObject['name'] }}
But what about if the property name is in another variable in scope? This doesnt work
{{ myObject['{{ anotherVar }}'] }}
Is something like this possible?
Upvotes: 1
Views: 1697
Reputation: 9269
{{}}
is meant to interpolate into html text. You are "already there". Try this:
{{ myObject[anotherVar] }}
I didn't test it. It's valid javascript, but I have no idea if it is valid "angular-script"
Upvotes: 5