[英]How to get values bound to ngValue in option element in an Angular 2 directive
I'm writing a directive in which I need to examine the value used with ngValue in option element.我正在编写一个指令,我需要在其中检查选项元素中与 ngValue 一起使用的值。 The directive sits on the parent.
该指令位于父级。 So, if I have the following HTML, is there a way to get to
item
inside directive validatable
?那么,如果我有以下 HTML,有没有办法进入指令
validatable
的item
?
<select [validatable]="trigger" [func]="foo.bind(this)">
<option *ngFor="let item of items" [ngValue]="item">{{item.s}}</option>
</select>
Thank you in advance.先感谢您。
you seem to be talking angularJS.你似乎在说 angularJS。 I don't think "directive" & "ngValue" are part of angular 2. And not exactly sure what you mean by "item inside directive validatable".
我不认为“指令”和“ngValue”是 angular 2 的一部分。并且不完全确定“指令中的项目可验证”是什么意思。
Maybe try something like this?也许尝试这样的事情?
<select (change)="validateItem($event.target.value)">
<option *ngFor="let item of items" [selected]="item.s == selectedItem">{{item.s}}</option>
</select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.