我有一个对象数组,我使用st-table指令显示。更新内容后更新智能表
我使用对象中某个字段的值来过滤表。 问题是,一旦这些对象中的某个字段的值被更改,则不会执行过滤。
我相信它的原因是smart-table监视数组的长度,但不会深入比较以查看任何对象内部的值是否发生更改。
我能做些什么来解决这个问题?
编辑:添加代码:
angular.module('myApp', ['smart-table'])
.controller('mainCtrl', ['$scope', '$timeout',
function ($scope, $timeout) {
$scope.rowCollection = [
{
name: "sth odd",
number: 1
},
{
name: "sth even",
number: 1
}
];
$scope.displayedCollection = [].concat($scope.rowCollection);
function changeNumber(){
$timeout(function(){
$scope.rowCollection[1].number = $scope.rowCollection[1].number === 1 ? 2 : 1;
changeNumber();
}, 1000);
}
changeNumber();
}
]);
http://plnkr.co/edit/IVYy5WrsiEJSRXZCqY9z?p=preview
注意,当您搜索如何如数字“2”,没有更新的观点,即使第二项的属性有时是“2 “而且有时候不是。
你能发表一些代码来重现这个问题吗? – svarog
@svarog,添加了代码和工作示例 – kihu