How to translate angular variables in template or ts file itself
HTML code - someComponent.html
<button (click)="changeLang('en')">En</button>
<button (click)="changeLang('de')">de</button>
<p>{{rate}}</p>
Ts File - someComponent.ts
rate:string="productRate";
changeLang(lang){
this.translate.use(lang);
this.traslate.get(this.rate).subscribe(res=>{this.rate = res;});
}
Json file-en.json
{ "productRate": "Product Rate" }
Json file-de.json
{ "productRate": "Produktpreis" }
I know how to do it in template using pipe but unable to do it in ts.
I had referenced stack overflow but unable to get the result. Please help