If '' is an Angular component, then verify that it is part of this module

前端 未结 16 3614
慢半拍i
慢半拍i 2020-12-07 14:09

I am new in Angular2. I have tried to create a component but showing an error.

This is the app.component.ts file.

import { Component } f         


        
16条回答
  •  北海茫月
    2020-12-07 14:58

    are you importing it in your app.module.ts like so and remove the directives bit:-

    @NgModule({
        bootstrap: [AppComponent],
        imports: [MyComponentModule],// or whatever the name of the module is that declares your component.
    
        declarations: [AppComponent],
        providers: []
    })
    export class AppModule {}
    

    Your MyComponentModule should be like this:-

    @NgModule({
        imports: [],
        exports: [MyComponentComponent],
        declarations: [MyComponentComponent],
        providers: [],
    })
    export class MyComponentModule {
    }
    

提交回复
热议问题