In my controller:
$scope.deleteUser = function(user){
$.ajax({
url: "/users/" + user.id.toString(),
method: "DELETE",
success: function(result){
$scope.users = result["users"];
alertify.success("done");
},
error: function () {
alertify.error("error");
}
});
return false;
};
when I clicked in delete button user successfully removed in the server. In success
function result["users"]
object contains one less users. But in template
%tr{"ng-repeat" => "user in showedUsers | filter: fio_filter"}
row count not lessen. But when I again clicked on delete button row is removed! why this?
Add the following line after your $scope.users = result["users"];
$scope.users = result["users"];
$scope.$apply();
Or, do this
$timeout(function() {
$scope.users = result["users"];
});
Please see the answer here https://stackoverflow.com/a/33810890/2405040 for detailed explanation. It is the exact same problem.