I have this code
<div *ngFor="let service of services">
<span><img [src]="service.imgPath" alt="{{ service.name }}"/></span>
<h4>{{ service.name}}</h4>
<p>{{ service.desc }}</p>
</div>
How can I do translation of each service that have 3 parameters
In regular case I use {{ 'something' | translate }}
, where "something" is
placed in .json file
"something" : "translation"
So how can a use it in state of ngFor? It read me an object from .json, but not array of objects that what I need in my case
First of all you will need to import ngx-translate in app.component.ts:
Then you need to have under assets two files one f.i en.json for English and another one for Spanish for instance, es.json containing two objects. In en.json:
In es.json:
Then, in your component where you have the code you mention:
In the template:
Note that your services object must contain something as string so it will be feasible to be translated.
Note - //make sure your json structure is correct