Reputation: 23
I'll start off with mentioning I'm very new to Angular so I'm probably not doing things in the correct "Angular way".
I have the following ng-repeat looping through some data - the correct data is being returned.
<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>
For some reason the ng-value on the input="text" fields doesn't show. I need to pass through the data from the field in to the updateAttribute() function, which is why I'm binding the model to the attr variable that I'm passing through. This variable is then being used for an API call.
If I take the model off the text fields I have the correct values, but I need someone of getting that value and passing it through to the function.
If there is another way that I should be doing this please let me know :)
Upvotes: 2
Views: 8624
Reputation: 1786
Ng-value is not ment for intput[text]
Binds the given expression to the value of input[select] or input[radio], so that when the element is selected, the ngModel of that element is set to the bound value.
Additionally ng-change expects expression so you do not have to use {{}}
use this instead
ng-change="updateAttribute(attr,attribute)"
Upvotes: 5