0
angular-cli
でプロジェクトをビルドしています。バージョン1.0.0-rc.2
にアップグレードした後、現在ng build
に問題があります。最新のアングルでビルドするときのプロバイダの問題
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 46:16 in the original .ts file), resolving symbol AppModule in /Users/Rkok/Documents/Projects/capitola-vr-frontend/src/app/app.module.ts
エラーがapp.module.ts
に位置しており、それは、プロバイダAPP_INITIALIZER
内useFactory
プロパティに接続されている:私はそうしようとすると、私は次のエラーを取得しています。これは完全なコードです:
@NgModule({
imports: [
// Modules list
],
declarations: [
// Declarations list
],
providers: [
{ provide: 'Window', useValue: Window },
PostsService,
UserService,
{
provide: APP_INITIALIZER,
useFactory: (users: UserService) =>() => users.onResize(), // The error is in this line
deps: [UserService],
multi: true
},
{
provide: APP_INITIALIZER,
useFactory: (posts: PostsService) =>() => posts.loadData(), // And in this other one
deps: [PostsService],
multi: true
}
],
bootstrap: [AppComponent]
})
export class AppModule {}
この問題を解決する最善の方法は何ですか。あなたの返信を前にありがとう!
ありがとうございますが、エラーは引き続き発生します。どうやら私はサービスや変数の中に関数を格納する必要があります。その方法で値を渡してください –
関数名を使用してuseFactory関数を宣言しようとすると、同じファイル内の@NgModuleデコレータを上書きし、 –
グローバル変数を使用するか、定数をエクスポートするのにtrieがありますが、エラーが再びスローされます。どのように宣言しますか? –