core icon indicating copy to clipboard operation
core copied to clipboard

Doc tweak: standalone components usage instructions

Open 0xfraso opened this issue 1 year ago • 3 comments
trafficstars

Hi there,

just opened this PR to help people find instructions about using ngx-translate in standalone based applications

hope you find this useful

0xfraso avatar Mar 01 '24 14:03 0xfraso

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')

}

markodjunev avatar Jun 16 '24 10:06 markodjunev

Hi @markodjunev, by default ngx-translate uses HttpClient as dependency, so make sure to put provideHttpClient() as provider into your bootstrap function.

0xfraso avatar Jun 27 '24 07:06 0xfraso

I've included it in the docs... https://ngx-translate.org/getting-started/translation-files/#standalone-components

CodeAndWeb avatar Sep 17 '24 09:09 CodeAndWeb