Reputation: 181
I'm trying to translate a number in i18n json file
"category":[{"1":"home"},{"2":"search"},{"3":"account"}]
and for *ngFor
<div *ngFor="let post of posts">
{{ post.category | translate }}
</div>
but the number is cannot translate to its value the category value return a number 1,2,3 I need to translate this result to a value from the json file
Upvotes: 1
Views: 482
Reputation: 6424
Consider the following approach:
"category":{
"1":"home",
"2":"search",
"3":"account"
}
Template:
<div *ngFor="let post of posts">
{{ "category." + post.category | translate}}
</div>
Upvotes: 1