Angular 4.x - ngx-translate - angular2-moment
How to use "amTimeAgo" and "amLocale" with dynamic locale? I mean, i.e this works
<p> {{ note.createdAt | amLocale: 'es' | amTimeAgo }} </p>
but I want to convert 'es' into a dynamic variable. What is the best approach? Using a Custom Pipe with ngx-translate service or... call from inside the component like this:
//myComponent.ts
ngOnInit() {
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
this.momentLang = event.lang;
});
}
// myComponent.html
<p> {{ note.createdAt | amLocale: momentLang | amTimeAgo }} </p>