Angular 2 Component is not part of any NgModule

前端 未结 9 2068
予麋鹿
予麋鹿 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 19:02

    Same issue here and i solved it.

    1) You create your component

                import { Component } from '@angular/core';
                @Component({
                  moduleId:module.id,
                  selector: 'page-home',
                  templateUrl:'HomeComponent.html',
                })
                export class HomeComponent  { }
    

    2) You should declare it in app.module.ts

                import {HomeComponent}  from './Components/Pages/Home/HomeComponent';
                ...
                declarations: [ 
                    AppComponent,
                    HomeComponent
                ],
    

    And the problem is fixed.

提交回复
热议问题