Prompt confirm before Leaving edited html form

后端 未结 6 1299
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 18:50

If user tries to leave unsaved edited form, a message box pop-up

\"This page is asking you to confirm that you want to leave - data you have entered may not be saved. Le

6条回答
  •  花落未央
    2021-02-04 19:01

    If you want to cancel the route change when you determine your form is dirty, you can do this:

    $rootScope.$on('$locationChangeStart', function(event) {
      event.preventDefault();
    });
    

    This will cancel the routing and keep you on the current page.

提交回复
热议问题