Unexpected value 'undefined' imported by the module

后端 未结 3 551
北海茫月
北海茫月 2021-01-19 04:21

I thought I understood how ngModule worked but apparently not. I have 3 modules: AppModule, AmpedFormsModule, and AmpedCommonMod

相关标签:
3条回答
  • 2021-01-19 05:00

    Its hard to say exact problem but there are few suggestions,

    1) change BroswerModule to CommonModule in AppCommonModule.Keep in mind BroswerModule should be imported by AppModule or RootModule only.

    @NgModule({
      imports       : [CommonModule, FormsModule],
      ...
    })
    

    2) Not sure but it seems you are creating circular dependencies by importing module into each other but as said not sure though.

    @NgModule({
      imports       : [FormsModule, AmpedFormsModule],      //<<< here
    })
    
    @NgModule({
      imports       : [ HttpModule, AmpedCommonModule ],    //<<< here
      ...
    })
    

    3) If AmpedFormsModule and AmpedCommonModule are lazy modules don't forget to put default keyword before class key word

    eg. export default class AmpedFormsModule {}
    
    0 讨论(0)
  • 2021-01-19 05:07

    I think the problem are circular dependencies. I have not analyzed your code in depth. But look my response on this post: Error: Unexpected value 'undefined' imported by the module maybe that helps.

    0 讨论(0)
  • 2021-01-19 05:21

    I faced same error , sometimes this issue occur and you only need to re-run the server using ng serve or whatever CLI you use

    0 讨论(0)
提交回复
热议问题