【发布时间】:2014-06-24 10:22:43
【问题描述】:
我首先要提到我对 Angular 很陌生,所以我可能没有以正确的“Angular 方式”做事。
我有以下 ng-repeat 循环遍历一些数据 - 正在返回正确的数据。
<tr ng-repeat="attribute in attributeCategory.attributes">
<td>
{{attribute.name}}
</td>
<td>
<input type="checkbox" ng-model="attr.enabled" ng-checked="{{attribute.parameters.enabled}}" ng-change="updateAttribute(attr, {{attribute.attribute_id}})"/>
</td>
<td>
<input type="checkbox" ng-model="attr.normalise" ng-checked="{{attribute.parameters.normalise}}" ng-change="updateAttribute(attr, {{attribute.attribute_id}})"/>
</td>
<td>
<input type="checkbox" ng-model="attr.reverse" ng-checked="{{attribute.parameters.reverse}}" ng-change="updateAttribute(attr, {{attribute.attribute_id}})"/>
</td>
<td>
<input type="text" ng-model="attr.min_threshold" ng-value="{{attribute.parameters.min_threshold}}" ng-change="updateAttribute(attr, {{attribute.attribute_id}})"/>
</td>
<td>
<input type="text" ng-model="attr.max_threshold" ng-value="{{attribute.parameters.max_threshold}}" ng-change="updateAttribute(attr, {{attribute.attribute_id}})"/>
</td>
<tr>
由于某种原因,input="text" 字段上的 ng-value 没有显示。我需要将字段中的数据传递给 updateAttribute() 函数,这就是我将模型绑定到要传递的 attr 变量的原因。该变量随后被用于 API 调用。
如果我从文本字段中删除模型,我有正确的值,但我需要有人获取该值并将其传递给函数。
如果我还有其他方法可以这样做,请告诉我 :)
【问题讨论】:
标签: javascript angularjs angularjs-scope angular-ngmodel