我正在尝试使用$ watchCollection函数将表(ui网格)与Angular中的另一个视图连接。
我需要$ watchCollection来监视表中的文本框(过滤器区域),并在识别出更改后根据过滤器值缩减文本。

我已经定义了UI网格<div ui-grid="gridOptions" ng-model="query" ui-grid-selection class="grid"></div>,现在我试图使用$ watchCollection在表中监视整个数组(过滤器):

 $scope.$watchCollection("query", function(newList, oldList) {
       $scope.newList = newList;
       $scope.oldList = oldList;
    });


当我写过滤器时,没有任何变化。
请查看plunker,我做错了什么?

最佳答案

添加true以在列表中查找任何值更改

$scope.$watchCollection("query", function(newList, oldList) {
   $scope.newList = newList;
   $scope.oldList = oldList;
}, true);

10-07 14:51