2016-09-02 32 views
16

मैं tsc के साथ अपने एप्लिकेशन संकलन जब मैं इस त्रुटि TS2345 मिलती है:Angular2 टाइपप्रति निर्देशक त्रुटि 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'. 

और यहाँ मेरे कोड है:

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

मैं में कुछ भी गलत नहीं दिखाई देता है मेरी कोड, यह भी काम करने के लिए प्रयोग किया जाता है। क्या कोई देख सकता है कि इसमें क्या गलत है?

नोट: मैं, Angular2-RC6 और टाइपप्रति 1.8.10 उपयोग कर रहा हूँ आशा है कि ये जानकारी में मदद करता है

+0

मैं एक ही बात यहाँ प्रयोग कर रहा हूँ। एक फिक्स के लिए खोज रहे हैं। – Tom

उत्तर

25

directives पदावनत और हटा दिया गया था। Time और Timeline अपने @NgModule घोषणाओं में अब जाना चाहिए:

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

मैंने यह किया, और मुझे अभी भी त्रुटि मिल रही है = (कोशिश करने के लिए और कुछ और? –

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 { 

} 
संबंधित मुद्दे