Uncaught Error: Unexpected directive 'ProductsComponent' imported by the module 'AppModule'. Please add a @NgModule annotation

前端 未结 2 1332
日久生厌
日久生厌 2021-01-22 12:59

Im trying to access the main route on my server at

http://localhost:4200

The full error message is:

Uncaught

相关标签:
2条回答
  • 2021-01-22 13:40

    You can import only classes adorned by @NgModule decorator. So move routingComponent from imports to declarations:

     @NgModule({
        declarations: [
          AppComponent,
          ProductsComponent,
          CartComponent,
          MenuComponent,
          routingComponents // add here
        ],
        imports: [
          BrowserModule,
          RouterModule,
          AppRoutingModule
        ],
        ...
    
    0 讨论(0)
  • 2021-01-22 13:45

    Try removing the routingComponents. I don't see that that is doing anything and may be causing this problem.

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