angularjs ng-repeat inside ng-repeat,the inside array can't update -
i come china,my english poor,so demo.how can update array inside ng-repeat
?
the html:
<body ng-app="main" ng-controller="democtrl"> <table ng-table class="table"> <tr ng-repeat="user in users"> <td data-title="'name'">{{user.name}}</td> <td data-title="'age'">{{user.age}}</td> <td> {{user.spms|json}} <div ng-repeat="u in user.spms"> <span ng-bind="u"></span> <input type="text" ng-model="u" ng-change='updatearray($parent.$index, $index, u)'> </div> </td> </tr> </table> </body>
the js:
var app = angular.module('main', []). controller('democtrl', function($scope) { $scope.users = [{ name: "moroni", age: 50, spms: [ 6135.7678, 504.4589, 2879.164, 669.7447 ] }, { name: "seven", age: 30, spms: [ 34135.7678, 5034.42589, 22879.1264, 63469.72447 ] } ]; $scope.updatearray = function(parent, index, u) { $scope.users[parent].spms[index] = u * 1; // multiply 1 keep value number } })
there issues here every update changing scope, can change 1 time them click change - recommend add update values button , implementing more or less same logic update array values.
Comments
Post a Comment