将isDevMode传递给Prod env中的forRoot引发错误

时间:2018-06-26 10:50:41

标签: javascript angular angular-cli

像下面这样的代码

const isDev = isDevMode()
const modules = [
    HttpClientModule,
    NgxsModule.forRoot(AllStates, { developmentMode: isDev }),
]

此代码在开发环境中可以很好地工作,但是会在prod环境中引发错误。 错误是Error during template compile of 'CoreModule' Function calls are not supported in decorators but 'isDevMode' was called.

是否可以将isDevMode传递给forRoot函数? 谢谢

1 个答案:

答案 0 :(得分:0)

最后,我使用const isDev = !environment.production,并且运行良好。