我的代码中的 ng-grid 有以下设置:
$scope.gridOptions = {
...
useExternalSorting : false,
}
$scope.watch('gridOptions.ngGrid.config.sortInfo', function (oldValue, newValue) {
console.log(newValue)
})
我也尝试使用sortInfo : undefined
and $watch(gridOptions.sortInfo)
。这似乎仅在网格最初加载时才有效。之后,当我单击标题列时,它似乎没有进入$watch
. 我尝试在触发排序的回调函数中放置一个调试器,我可以看到代码用正确的信息更新了 sortInfo 数组,但是它似乎没有进入 watch 语句的回调函数中。我的设置有什么不正确的地方吗?我在这里有一个 Plunker,它与我正在尝试做的事情类似。