我想将旧值与ng-grid(AngularJS)中cellTemplate的输入文本框的新值进行比较。
$scope.templateArray =[
{
field: "NP",
displayName: "Nameplate",
width: "*"
},
{
field: "Qty",
displayName: "Qty",
width: "30px",
cellTemplate: "<input ng-class=\"\'colt\' + col.index\" ng-input=\"COL_FIELD\" ng-model=\"COL_FIELD\" ng-model-options=\"{updateOn: 'default blur', debounce: {default: 0, blur: 0}, allowInvalid: false}\" ng-change=\"$scope.UpdateItemQty(row)\" />",
enableCellEdit: true
},
{
field: "NPPos15",
displayName: "Location",
width: "*"
}];
我尝试了两种方法来实现它,一种使用ng-change
(在这种情况下我总是获得新的更新值),第二种使用AngularJS $watch
(在这种情况下我不知道是什么将是$watch
名称。假设我使用*$watch
名称&#34; inputQty&#34;然后我应该使用这个名称将其与ng-grid的单元格模板链接(我尝试将其放在输入文本框中作为id
,但它不起作用)。
$scope.$watch('inputQty', function (newQty, oldQty) {
console.log('being watched oldValue:', oldValue, 'newValue:', newValue);
}, true);
我如何在ng-grid
cellTemplate中实现它?