This might be a trivial thing to do, but i'm a angularjs newbie. Here is my angularjs controller code
function MyCtrl1($scope, $location, $rootScope) {
$scope.$on('$locationChangeStart', function (event, next, current) {
event.preventDefault();
var answer = confirm("Are you sure you want to leave this page?");
if (answer) {
}
});
}
MyCtrl1.$inject = ['$scope', '$location', '$rootScope'];
In the next variable i have the url to redirect on confirm OK.But how to accomplish this thing in angularjs.