[英]Accessin ng-options variable in ng-change
Seemingly simple issue here. 看似简单的问题在这里。 I have an ng-options select tag that's working funky.
我有一个ng-options select标签,它很时髦。
Basically my ng-change function does not work properly, as the first parameter, "v", is undefined. 基本上,我的ng-change函数无法正常运行,因为第一个参数“ v”未定义。 Any help?
有什么帮助吗?
<select ng-model="d.sub_customer" ng ng-options="v.description as v.description for v in subCustomers" ng-change="updateCustomer(v,d.id)"></select>
You cannot access the iteration variable in ng-options
expression outside (unlike ng-repeat
). 您无法在
ng-options
表达式外部访问迭代变量(与ng-repeat
不同)。 Because ng-options just uses that expression and draws the options for the select in DOM. 因为ng-options仅使用该表达式并为DOM中的select绘制选项。 It really does not create a scope to keep hold off these properties, which is why it is unlike ng-repeat.
它实际上并没有创建保留这些属性的作用域,这就是为什么它与ng-repeat不同的原因。 In your case
d.sub_customer
will be the selected v.description
,so you could just pass in that in the ng-change, ie 在您的情况下,
d.sub_customer
将是选定的v.description
,因此您可以在ng-change中将其传递,即
ng-change="updateCustomer(d.description,d.id)"
<select ng-model="d.sub_customer" ng ng-options="v.description as v.description for v in subCustomers" ng-change="updateCustomer(v,d.sub_customer)"></select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.