在AngularJS {ng}中以ng-grid格式比较cellTemplate输入文本框的新旧值

时间:2017-07-31 13:50:27

标签: angularjs ng-grid angularjs-ng-change angularjs-watch

我想将旧值与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中实现它?

0 个答案:

没有答案