3

I am trying to use modal dialog of bootstrap to ask for confirmation to navigate when the page is in edit mode.

I am using $locationChangeStart event to find out change in navigation. I am using a bool flag to find if the current page is in edit mode. In edit mode I should show the modal dialog on $locationChangeStart event trigger.

The dialog would contain Yes(To navigate away from the current page) or No(to stay on the same page).

I have used bootstrap modal dialog. My code would look like:

This is inside controller:

$scope.$on('$locationChangeStart', function (event, next, current) {

                if (vm.isEditMode) {

                    event.preventDefault();
            }

I have created a angular directive for modal dialog. How would I call event.preventDefault() inside directive, on click of "No" by the user?

Vidya Sagar
  • 1,699
  • 3
  • 17
  • 28
user2439903
  • 1,277
  • 2
  • 34
  • 68

0 Answers0