Angular2 TypeScript指令错误TS2345

tho*_*ght 17 angular

当我用tsc编译我的应用程序时,我收到此错误TS2345:

error TS2345: 
Argument of type '{ selector: string; template: string; directives: (typeof Title | any[])[]; providers: typeof Goo...' is not assignable to parameter of type 'ComponentMetadataType'.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import { Component, Input } from "@angular/core";
import { Title } from "./components/title";
import { Timeline } from "./components/timeline";

@Component({
  selector: "edu",
  template: `
            <div id="Edu" class="Edu content section scrollspy">
              <title [icon]="titleIcon" [title]="titleTitle"></title>
              <timeline [data]="edu"></timeline>
            </div>
            `,
  directives: [Title, Timeline]
})

export class Edu {
  private titleIcon = "graduation-cap";
  private titleTitle = "Education";
  @Input("data") edu: Array<Object>;
}
Run Code Online (Sandbox Code Playgroud)

我的代码中没有看到任何错误,它也曾用过.有人能看出这有什么问题吗?

注意:我正在使用Angular2-rc6和TypeScript 1.8.10,希望这些信息有所帮助

j2L*_*L4e 26

directives已弃用并已删除. Time并且现在Timeline应该在你的@NgModule声明中:

@NgModule({
  declarations: [Time, Timeline, ...],
  ...
})
Run Code Online (Sandbox Code Playgroud)