javascript - AngularJS detect which input has been changed -


data retrieved in angularjs app via $http.get , rendered this:

# angular app.controller('mainctrl', function ($scope, $http) {     $scope.cart = {};      $scope.cart.retrieve = function() {         // make $http retrieve data         .success(function(results) {             $scope.cart.contents = results         });     };      $scope.cart.update = function(itemid) {         // make $http request 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 item quantity changed in input field, function passes item id fires: $scope.cart.update = function(itemid) { ... } . how retrieve new quanity value particular item triggered on-change event. there in angular this can use inside function?

you can pass item cart.update function:

on-change="cart.update(item)" 

and use qty of item

$scope.cart.update = function(item) {     // whatever want     // item.qty } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -