Simple to-do list, but with a delete button on list page for each item:
Relevant template HTML:
-
To remove a element from scope use:
// remove an item
$scope.remove = function(index) {
$scope.items.splice(index, 1);
};
From enter link description here
讨论(0)
-
Angular have a built-in function called arrayRemove
, in your case the method can simply be:
arrayRemove($scope.persons, person)
讨论(0)
-
For the the accepted answer of @Joseph Silber is not working, because indexOf returns -1. This is probably because Angular adds an hashkey, which is different for my $scope.items[0] and my item. I tried to resolve this with the angular.toJson() function, but it did not work :(
Ah, I found out the reason... I use a chunk method to create two columns in my table by watching my $scope.items. Sorry!
讨论(0)
-
array.splice(array.pop(item));
讨论(0)
- 热议问题