我将首先提到我对 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 调用。
如果我将模型从文本字段中取出,我将获得正确的值,但我需要有人获取该值并将其传递给函数。
如果有另一种方法我应该这样做,请告诉我:)