2017-08-18 5 views
1

マイエラー:角2 - 属性ディレクティブ構文のエラー。何も見逃しましたか?

ERROR in C:/smartphoneSalesApp/src/app/test.directive.ts (9,3): Declaration expe 
cted. 

ERROR in C:/smartphoneSalesApp/src/app/dashboard/dashboard.component.ts (7,3): A 
rgument of type '{ selector: string; templateUrl: string; directives: typeof tes 
tDirective[]; }' is not assignable to parameter of type 'Component'. 
    Object literal may only specify known properties, and 'directives' does not ex 
ist in type 'Component'. 

マイ部品コード:

import { Component } from '@angular/core'; 
import { testDirective } from '../test.directive'; 

@Component({ 
    selector: 'dashboard', 
    templateUrl: './dashboard.component.html', 
    directives: [testDirective] 
}) 

export class DashboardComponent { 
    title = 'Welcome to Dashboard'; 
} 

私はこのエラーを取得していますなぜ私は殿。私はディレクティブに関連する角コアモジュールをインポートする必要がありますか?

答えて

0

あなたのコードには二つの問題があります:あなたはちょうどあなたがここに余分なセミコロンを持って@NgModule

  • にディレクティブを登録する必要がありますので、

    1. ディレクティブプロパティは、もはや@Componentデコレータでサポートされていますが:

    @Directive({se... 'onMouseLeave()'}}); <----

  • +0

    宣言:[AppComponent、DashboardComponent、SmartphoneListComponent、追加SmartphoneComponent、SmartphoneComponent、sortSmartphonePipe、testDirective、TestComponentComponent]、私はすでにそれを追加しました。 –

    +0

    @PalzPal、それでいいです、コンポーネントからそれを取り除いてから –

    +0

    はい削除しました。 C:/smartphoneSalesApp/src/app/test.directive.ts(9,3)のエラー:と書かれています。 –

    関連する問題