I am working angular 4 application and trying to pass the current language to the toLocaleString() method. The method mathoround is static method and doesnt understand this.translation.currentLang. How do I pass a non static object to static method.
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
@Injectable()
export class ChartHelperService {
constructor( private translation: TranslateService) { }
static prepareChartTooltipRow(name: string, value: string, additionalStyle: string): string {
return '<tr style="background-color: initial;"><td style="text-align:left;' + additionalStyle + '"><b>' + name +
'</b></td>' +
'<td style="text-align: right;' + additionalStyle + '">' +
value +
'</td></tr>';
}
static showCcorYAxis(id: number): boolean {
return !(window.innerWidth < 992 && id !== 0);
}
static mathRound(input: number): string {
return Math.round(input).toLocaleString(this.translation.currentLang, { maximumFractionDigits: 0 });
}
}