Angular.js - ng-model在文本输入上覆盖我的ng值

use*_*721 2 javascript angularjs angularjs-scope angular-ngmodel

我首先提到我对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>
Run Code Online (Sandbox Code Playgroud)

由于某种原因,input ="text"字段上的ng值未显示.我需要将字段中的数据传递给updateAttribute()函数,这就是我将模型绑定到我正在传递的attr变量的原因.然后,此变量用于API调用.

如果我从文本字段中取出模型,我有正确的值,但我需要有人获得该值并将其传递给函数.

如果还有其他方式我应该这样做,请告诉我:)

mar*_*inn 5

Ng值不是输入[文本]

将给定表达式绑定到input [select]或input [radio]的值,以便在选择元素时,将该元素的ngModel设置为绑定值.

查看文档

另外ng-change需要表达式,因此您不必使用{{}}

改用它

ng-change="updateAttribute(attr,attribute)"
Run Code Online (Sandbox Code Playgroud)