2016-09-02 12 views
16

Kiedy mogę skompilować mojej aplikacji z TSC otrzymuję ten błąd TS2345:Angular2 dyrektywa maszynopis błąd 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'. 

I tu jest mój kod:

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>; 
} 

nie widzę niczego złego w moim kod, również kiedyś działał. Czy ktoś może zobaczyć, co jest nie tak z tym?

Uwaga: Używam Angular2-rc6 i maszynopis 1.8.10, nadzieję, że te informacje pomaga

+0

mam eksperymentowanie to samo tutaj. Szukam poprawki. – Tom

Odpowiedz

25

directives została zaniechana i usunięte. Time i Timeline powinien iść w swoich oświadczeniach @NgModule teraz:

@NgModule({ 
    declarations: [Time, Timeline, ...], 
    ... 
}) 
+0

Zrobiłem to i nadal otrzymuję błąd = (Coś jeszcze, aby spróbować? –

4
#--------------app.module.ts 
import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 

import { AppComponent } from './app.component'; 
import { Time} from './Time.component' 
import { Timeline} from './Timeline.component' 

@NgModule({ 
    imports:  [ BrowserModule ], 
    declarations: [ AppComponent, TimeComponent, TimelineComponent ], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { } 

#--------------app.component.ts 
import { Component } from '@angular/core'; 

@Component({ 
    selector: 'my-app', 
    template: `<h1>{{title}}</h1> 
    <time></time> 
    <timeline></timeline> 
    ` 
}) 
export class AppComponent { 
    title = 'My Title'; 
} 

#--------------time.component.ts 
import { Component } from '@angular/core'; 
@Component({ 
    selector: 'time', 
    template: `<p>Do Something With Time Here</p>` 
}) 
export class TimeComponent { 

} 
#--------------timeline.component.ts 
import { Component } from '@angular/core'; 
@Component({ 
    selector: 'timeline', 
    template: `<p>Do Something With Timeline Here</p>` 
}) 
export class TimelineComponent { 

} 
Powiązane problemy