0
我想知道某個組件是否設置了[(ngModel)]
。檢測組件是否在Angular 2中設置了NgModel
我正在創建一個typeahead組件,並且想知道ngModel是否設置爲元素。
事情是這樣的:
我-form.component.html
...
<my-custom-typeahead [(ngModel)]="somevariable" name="someinput1"><my-custom-typeahead>
<my-custom-typeahead name="someinput2"><my-custom-typeahead>
...
我定製-typeahead.component.ts
@ngModule({
...
selector: 'my-custom-typeahead',
...
})
export class myCustomTypeaheadComponent{
// I would like to know if the ngModel was set in the component
// something like @Host('my-custom-typeahead').has2wdb('ngModel')
}
我認爲使用@host不是答案,但這是我可以更多地解釋它的方式。
請澄清你的問題。也許添加一些代碼..不能關注.. – mxii
@mxii我編輯了我的問題,並提供了我想要做的一個例子。謝謝你的時間! – vinagreti