I have implemented a confirm button where the confirm button will remove a user from the list. But for some reason, it does not remove the user from the list. Can anyone check my js code to see what I have done wrong.
Here is my code
$scope.doDelete = function(user) {
var index = $scope.userInfo.users.indexOf(user);
$scope.userInfo.users.splice(index, 1);
$window.location.href = '#/user';
}
html
<button class="delete" ng-click="doDelete(person)">Confirm</button>
console.log(indexOf);?indexis assigned (the line below) doconsole.log(index)and make sure you're passing a valid index to splice. It will also help to see what$scope.userInfo.userslogs out as wellindexid number. Such as 1.$windows.location.href. But you're doing it right. Just you're reloading your page, so the data is reinitialised