I have this example which a basic list with the option to remove items.
When the user tries to remove something, a confirmation is required. But also, to demonstrate which item will be deleted I've changed the table row colour conditionally.
The problem is, I could not make the colour of the selected row change without using $scope.$apply() before the confirm() statement.
$scope.removeEntry = function(index) {
    $scope.entries[index].toBeRemoved = true;
    $scope.$apply();
    if (confirm("Are you sure you want to delete this item?") === true) {
        $scope.entries.splice(index, 1);
    }else{
        $scope.entries[index].toBeRemoved = false;
    }
};
But this gives me:
Error: [$rootScope:inprog] $apply already in progress
Am I missing something or is there any better way to do it and preventing this?
I've already tried almost all suggestions on this answer without success.
 
     
     
    