I am using ng2-translate on my ionic2 app, and it's working nicely on static text on html files:
<button ion-item *ngFor="let examTaken of examTakenList" (click)="selectExamTaken(examTaken)">
{{'menu.'+examTaken.name | translate }} - {{examTaken.createdAt | date: "dd.MM.yyyy"}}
</button>
But I don't know how to translate strings on component files combined with charts.js like:
@Input() examTakenList: Promise<Array<ExamTaken>>;
lineChartData: Array<any> = [
{ data: [], label: 'Richtige Antworten in %' }
];
lineChartLabels = new Array<string>();
lineChartOptions: any = {
animation: false,
responsive: true
};
I want to translate the label: 'Richtige Antworten in %'.
How can I use ng2-translate pipe in typescript and JavaScript files ?
Thanks in Advance
I dont know in jaavascript, but in typescript you should import :
import {TranslateService} from "ng2-translate";
Load it into your constructor :
constructor(private translate : TranslateService) { }
and use it into your code like this:
this.translate.instant("global.congratulation")
This one is working to me.