Angular 2 Component is not part of any NgModule

前端 未结 9 2047
予麋鹿
予麋鹿 2020-12-08 18:12

i\'m upgrading my Angular 2 project from RC5 to 2.0.0. I get this Error

Unhandled Promise rejection: Component LoginComponent is not part of any NgM

9条回答
  •  囚心锁ツ
    2020-12-08 18:52

    In My case, the problem was with the capitalization difference in app.routing.ts and app.module.ts. We need to make sure we have the same path with the same case specified in both the locations.

    Earlier

    app.routing.ts => import { HomeComponent } from './components/home.component';
    app.module.ts => import { HomeComponent } from './Components/home.component'

    Solution

    app.routing.ts => import { HomeComponent } from './Components/home.component';
    app.module.ts => import { HomeComponent } from './Components/home.component'

    Note, the change in case of folder named "Components"

提交回复
热议问题