Data is retrieved in my AngularJS app via $http.get and rendered like this:
# Angular
app.controller('MainCtrl', function ($scope, $http) {
$scope.cart = {};
$scope.cart.retrieve = function() {
// make $http to retrieve data
.success(function(results) {
$scope.cart.contents = results
});
};
$scope.cart.update = function(itemId) {
// make $http request to update cart
}
});
# HTML
<table ng-init="cart.retrieve()">
<tbody>
<tr ng-repeat="item in cart.contents">
<td>{{ item.price }}</td>
// item quantity input field
<td><input type="number" name="quantity" on-change="cart.update(item.id)"
ng-model="item.qty"></td>
<td>{{ item.price * item.qty }}</td>
</tr>
</tbody>
</table>
When the item quantity is changed in input field, the function that passes item id fires: $scope.cart.update = function(itemId) { ... } . How do I retrieve this new quanity value for this particular item that triggered on-change event. Is there something in angular like this I can use inside the function?