RooksStrife RooksStrife - 1 year ago 104
AngularJS Question

How to pass a ng-repeat item as a value into Angular Translate?

It is easier to display this than explain it. I am trying to do this...

<div ng-repeat="label in itemLists">
<input id="{{label}}" type="checkbox">
<label for="{{label}}">{{'food.items.{{label}}' | translate}}</label>

The translate with the {{label}} is the issue. If I use food.items.cheese it works.

and inside of itemLists is

['lettuce', 'cheese', etc...]

food items is

"lettuce": "Lettuce",
"cheese": "American Cheese",

Answer Source

You can't have {{}} inside of {{}}.
How about 'food.items.' + label?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download