1

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?

1 Answer 1

5

{{}} 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"

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.