I have a form-like page with some data. And want to show a popup/alert when a user clicks the browser back button, asking "if they want to go back or stay on the same page". I am using angular-ui-router's $stateProvider
and want to bind this only to one state/view.
Join them; it only takes a minute:
|
|||||||||
|
This is my previous answer for some another question. but it's now helps to you You can do it by using angular $routeChangeStartBroadcasted before a route change. At this point the route services starts resolving all of the dependencies needed for the route change to occur. Typically this involves fetching the view template as well as any dependencies defined in resolve route property. Once all of the dependencies are resolved $routeChangeSuccess is fired. The route change (and the So please try this below code.
Update:You need to write your functional works in the model popup. like Put some link buttons for
then Add ng-click event for go prev page, stay current page with using DOES MAKE SENSE DUDE? |
|||||||||||||||||||||
|
You'd be better off using $stateChangeStart event with angular ui router. There will be problems with $routeChangeStart as $routeChangeStart event will be triggered when the url changes. For example:You have 4 states, each with 2 sub-state, and each sub/state or state is not associated with a url. In such cases listening to $routeChangeStart might not work. In the controller/view where you want to prompt the user to confirm the redirection do this. This will be called when the state changes in your current scope (which is the view/controller that you are in)
|
|||
|
Here is my solution
|
|||||
|