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