分叉你的 plunker 使用一些随机值更改“x(默认)”列的值。
码:
angular.forEach($scope.myData,function(row,idx){ row.x = Math.random(); });
建议不要使用观察者来实现功能。而是使用功能。
您可以收听更改和更新 $scope.myData 什么时候 discount 变化。以来, ui-grid 有双向绑定 $scope.myData 它会更新视图。 您 input 标签看起来像:
$scope.myData
discount
ui-grid
input
<input class="form-control " data-ng-model="discount" ng-change="updateValues()" type="number">
然后添加 updateValues 功能你的 $scope :
updateValues
$scope
$scope.updateValues = function() { // write code to update values here }