Angular2 RC6升级

将我的项目更新为RC6后发生以下错误
Error: Typescript found the following errors:
  app.component.ts (12,3): Argument of type '{ moduleId: string; selector: string; templateUrl: string; styleUrls: string[]; directives: (type...' is not assignable to parameter of type 'ComponentMetadataType'.
  Object literal may only specify kNown properties,and 'directives' does not exist in type 'ComponentMetadataType'.

app.component.ts

import {Component,OnInit} from '@angular/core';
import {NavbarComponent} from "./shared/navbar/navbar.component";
import {ROUTER_DIRECTIVES} from "@angular/router";
import {SidebarComponent} from "./shared/sidebar/sidebar.component";
import {FooterComponent} from "./shared/footer/footer.component";

@Component({
  moduleId: module.id,selector: 'app-root',templateUrl: 'app.component.html',styleUrls: ['app.component.css'],directives: [NavbarComponent,SidebarComponent,FooterComponent,ROUTER_DIRECTIVES]
})
export class AppComponent implements OnInit {

  ngOnInit(): any {
    return undefined;
  }

}

我需要一段时间,但我无法弄明白.

必须在@NgModule中定义指令和管道如果我正确读取. @Component内的支持删除.

所以,只需将您的指令移动到NgModule中

目前你有:组件A的指令为Ac,组件B的指令为Bc,很可能是一个AppModule,你只需要将Ac和Bc移动到AppModule中.是的,你必须从@Component声明中删除它们

然后,指令将立即在模块中定义的组件中可用.

OP的示例变为:

app.component.ts

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

app.module.ts

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

请参阅路由器的文档:router documentation

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...