Can someone help me with a problem? nf n I have an array of objects that appears in a table and I have a search. Each object represents one row in the table. The main problem is the array. We can change it at any time (you can add new rows, delete existing rows and change the value in the table), even if we are looking for something.
Now I have something like this:
$scope.$watch( 'search', function() {
if($scope.search!== "") {
if(! $scope.initArray.length) {
$scope.initArray= $scope.array;
}
$scope.array= $filter('filter')($scope.initArray, function(item) {
return item.name1.indexOf($scope.search) > -1 ||
item.name2.indexOf($scope.search) > -1 ||
item.name3.toLowerCase().indexOf($scope.search) > -1;
});
} else {
$scope.array= $scope.initArray;
}
});
As you can see, I use two arrays. Everything is fine, but when I want to change $ scope.array, I need to change $ scope.initArray. And that causes a lot of problems.
, 3 . 3 . - , ( colomn). . , , . , . $scope.initArray $scope.array. , , .
, ?
$scope.array .
$scope.initArray ( )