Ngrx问题与角度的AOT

时间:2017-12-24 16:16:13

标签: angular redux ngrx

我已经使用redux(ngrx)创建了我的应用程序,它在开发模式下工作正常,但在生产版本中,我使用AOT并且它给了我这个错误Uncaught TypeError: Cannot convert undefined or null to object,这里它说来源是combineReducers。如何解决这个问题。这是我的代码:

// reducer.ts

import { DynamicComponent, FieldTypeReducer, FormCreate, FormGroup, FormList, FormTemplates, FormPreview, FormView } from './forms';

const reducers = {
    dynamicComponent: DynamicComponent,
    fieldType: FieldTypeReducer,
    formCreate: FormCreate,
    formGroup: FormGroup,
    formList: FormList,
    formTemplates: FormTemplates,
    formPreview: FormPreview,
    formView: FormView
};

export default reducers;


// app.module.ts
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';

import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { StoreModule, ActionReducer, MetaReducer } from '@ngrx/store';

// Reducer
import reducers from './reducer';


@NgModule({
  imports: [

    StoreModule.forRoot(reducers),
    StoreDevtoolsModule.instrument({
      maxAge: 25
    })
  ],
  providers: [],
  declarations: [
    AppComponent
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  bootstrap: [AppComponent]
})
export class AppModule { }

1 个答案:

答案 0 :(得分:0)

此处使用nrgx存在此AOT编译错误的修复: fix(Store): Use existing reducers when not using an InjectionToken