core
core copied to clipboard
Doc tweak: standalone components usage instructions
Hi there,
just opened this PR to help people find instructions about using ngx-translate in standalone based applications
hope you find this useful
I did exactly the same thing. However I got the following error TypeError: this.handler.handle is not a function on translate.use(). This is my code:
@Component({ selector: 'app-header', standalone: true, imports: [CommonModule, TranslateModule], templateUrl: './header.component.html', styleUrl: './header.component.css' }) export class HeaderComponent { private languages: string[] = ['fr', 'en'];
constructor( protected translate: TranslateService ) { translate.addLangs(this.languages);
translate.use('en')
}
Hi @markodjunev, by default ngx-translate uses HttpClient as dependency, so make sure to put provideHttpClient() as provider into your bootstrap function.
I've included it in the docs... https://ngx-translate.org/getting-started/translation-files/#standalone-components