Created
August 5, 2014 08:54
-
-
Save richmwatts/7f3dd530087378759992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.detachLocationChangeListener = $scope.$on('$locationChangeStart', function (event, next, current) { | |
event.preventDefault(); //prevent the navigation | |
$scope.showSaveChangesDialog = true; //dialog control | |
$scope.nextRoute = $location.url(next).hash(); //grab requested location | |
}); | |
$scope.confirmSaveChanges = function (answer) { | |
if (answer == true) { | |
alert("clicked yes, save changes"); | |
} | |
else{ | |
alert("clicked no, discard changes"); | |
} | |
$scope.detachLocationChangeListener(); | |
$location.path($scope.nextRoute); //regardless the action we want to navigate to the request location | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment