Angular2 RC6 upgrade

前端 未结 3 827
轮回少年
轮回少年 2021-01-12 16:13

after updating my project to RC6 following errors occurs:

Error: Typescript found the following errors:
  app.component.ts (12, 3): Argument of          


        
3条回答
  •  死守一世寂寞
    2021-01-12 16:47

    Directives and pipes must be defined in @NgModule If I'm reading correctly. Support inside @Component is removed.

    So yeah just move your directives into the NgModule

    At the moment you have : Component A with directives Ac and Component B with directives Bc and most likely one AppModule, you just have to move Ac and Bc into the AppModule. And yes, you have to remove them from the @Component declaration

    The directives will then be immediately available in the components that are defined in your module.


    Example from OP becomes:

    app.component.ts

    // imports...
    @Component({
      selector: 'app-root',
      templateUrl: 'app.component.html',
    })
    export class AppComponent {}
    

    app.module.ts

    // imports...
    @NgModule({
      declarations: [
        AppComponent,
        NavbarComponent, 
        SidebarComponent, 
        FooterComponent
      ],
      imports: [
        BrowserModule,
        CommonModule,
        FormsModule
      ],
      providers: [
                   //MyService, MyOtherService
                 ],
      entryComponents: [AppComponent],
      bootstrap: [AppComponent]
    })
    export class AppModule {}
    

    See the doc for router: router documentation

提交回复
热议问题