0
属性ディレクティブに問題があります。ディレクティブの文字列属性に関する問題
私は次のディレクティブに定義されている:
import {Directive, Input, ElementRef} from 'angular2/core';
@Directive({
selector: '[chooseMe]'
})
export class ChooseMe {
@Input('chooseMe') data: string;
constructor(private _elementRef:ElementRef) {
console.log(this.data);
}
}
をそして、私はそのようにそれをフック:
<button [chooseMe]="example"> W/E</button>
そしてもちろん、私のコンポーネントに私が持っている:しかし
@Component({
...,
directives:[ChooseMe]
})
、 this.data
はそれぞれ定義されていません。私のミスはどこですか?
ギュンターが正確である - ちょうどあなたのコードでそれをチェック - http://plnkr.co/edit/UoE1mIvfympVxPe6rNtd?p=preview – micronyks
はたぶん 'example'は'まだあります定義されていない? –
@GünterZöchbauer、あなたは正しいです - 私は普通の文字列を渡したいと思います。出来ますか? – uksz