Dynamic variable

12 views
Skip to first unread message

Norman Braun

unread,
May 2, 2016, 6:33:22 AM5/2/16
to AngularJS
just a syntax problem

ng-bind="lang.category.car"

... works, but i have car in a var and want to use ...

ng-bind="'lang.category.'+value.name"

... but it is not woking

hope somebody can help me.

thx
Norman

Sander Elias

unread,
May 2, 2016, 9:27:35 AM5/2/16
to AngularJS
Hi Norman,

in 50% of the us cases this is a code smell.
However, in case you are in the 50% that is not, you can do it like this:

ng-bind="lang.catagory[value.name]"

Does that help you?

Regards
Sander
Reply all
Reply to author
Forward
0 new messages