1.Background
Angular 更新至V16版后,支援 standalone,故移除了 NgModule,而TranslateModule 又要在AppModule中 import,那该如何做呢?
2.NPM packages installation
npm install @ngx-translate/core
npm install @ngx-translate/http-loade
3.Import TranslateModule in bootstrapApplication of main.ts
// import ngx-translate and the http loader
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient, HttpClientModule } from '@angular/common/http';
// required for AOT compilation
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http);
}
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(
NzMessageServiceModule,
NzDrawerServiceModule,
NzModalModule