boolean
装饰器中使用返回
NgModule
的函数?我的项目是 Angular 16。这是我的
app.module.ts
:
import { NgModule, isDevMode } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { StoreModule } from '@ngrx/store';
import { reducers, metaReducers } from './store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
StoreModule.forRoot(reducers, { metaReducers }),
isDevMode() ? StoreDevtoolsModule.instrument() : [], // <- This is what makes my code to throw error!
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
这是我遇到的错误:
Value at position 2 in the NgModule.imports of AppModule is not a reference
Value could not be determined statically.(-991010)
app.module.ts(15, 5): Unable to evaluate this expression statically.
app.module.ts(15, 5): A value for 'isDevMode' cannot be determined statically, as it is an external declaration.
(alias) isDevMode(): boolean
import isDevMode
Returns whether Angular is in development mode.
By default, this is true, unless enableProdMode is invoked prior to calling this method or the application is built using the Angular CLI with the optimization option.