Search code examples
angularjsangular-translate

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>
</div>

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",
            etc...
        }

Solution

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