Sunday, 18 August 2013

How to remove elements/nodes from angular.js array

How to remove elements/nodes from angular.js array

I am trying to remove elements from the array $scope.items so that items
are removed in the view ng-repeat="item in items"
Just for demonstrative purposes here is some code:
for(i=0;i<$scope.items.length;i++){
if($scope.items[i].name == 'ted'){
$scope.items.shift();
}
}
I want to remove the 1st element from the view if there is the name ted
right? It works fine, but the view reloads all the elements. Because all
the array keys have shifted. This is creating unnecessary lag in the
mobile app I am creating..
Anyone have an ideas to this solution please?
Thanks,
Nick

No comments:

Post a Comment