How to use Ng2-translate into *NgFor

475 views Asked by At

i need to translate the Data that i get in NgFor but i couldn't find any solution for it.

can any 1 find solution for this

<dl class="row">
    <dd class="col-sm-3" (click)="onSelect(brand)" *ngFor="let brand of searchData">
        <div style="text-align:center">{{brand.name}}</div>
        <br> 
    </dd>
</dl>

how can i use | translate @pipe inside this NgFor

2

There are 2 answers

0
RAJKAMAL MM On BEST ANSWER

GOT THE SOLUTION THIS IS WORKING FINE

    <dl> <dd> 
    <div class="col-md-3" (click)="onSelect(brand)" *ngFor="let brand of searchData">
 <br>{{'HOME.'+brand.name | translate}}
     <br></div> 
    </dd> </dl>
0
Pinto Xavier On

If you are driving it from a ngFor then do it in the following way.

*ngFor="let brand of searchData" 
  
{{ ''+brand.name+'' | translate }}

this will help in generating the string from the object variable brand.name