To many $digest runs


#1

This question is more about AngularJS then Ionic.

i have a List with option to delete a item.
And i use following method to delete a list item:

 $scope.delete = (idx) => {
	var delItem = $scope.Persons[idx];
	Person.delete(delItem.id).then(() => {
		
		$scope.Persons.splice(idx, 1);
	});
};

this works fine the first time, when i delete a 2nd one it will remove multiple items.
i think this is due to $digest what runs multiple.

when i change the code to this:

$scope.delete = (idx) => {
	var delItem = $scope.Persons[idx];
	Person.delete(delItem.id).then(() => {
		
		Person.all().then(function(persons) {
			$scope.Persons = persons;
		});
	});
};

it works fine, but i think with a big list it is not performance optimized.

do you know how to prevent this form happening(splice)