translation - Angular 2.0 translate Pipe could not be found -
i have component uses translateservice, it's not possible translate items pipe on component template html, following error:
the pipe 'translate' not found
app.module.ts
import {browsermodule} "@angular/platform-browser"; import {ngmodule} "@angular/core"; import {httpmodule, http} "@angular/http"; import {translatemodule, translateloader, translatestaticloader} 'ng2-translate'; import {appcomponent} "./app.component"; @ngmodule({ declarations: [appcomponent], imports: [ browsermodule, httpmodule, translatemodule.forroot({ provide: translateloader, usefactory: (http: http) => new translatestaticloader(http, './assets/i18n', '.json'), deps: [http] }) ], bootstrap: [appcomponent] }) export class appmodule { } booking.component.ts
import {component, oninit} '@angular/core'; import {bookingcomponent} './booking.component'; import {translateservice} 'ng2-translate'; @component({ selector: 'app-booking', templateurl: './booking.component.html', styleurls: ['./booking.component.css'] }) export class bookingcomponent implements oninit { constructor(private translate: translateservice ) { translate.setdefaultlang('de'); translate.use('de'); }; ngoninit() { } } booking.component.html
<p>{{'testkey' | translate }}</p> the translation service on component works fine, need translate html pipe
you need imports: [ translatemodule ] whatever module bookingcomponent declare in. import in app module makes pipes available components declared in module. providers/services globally registered module (unlike components, directives, , pipes)
Comments
Post a Comment