Based on Rishabβs answer and using the sergey location.skipReload from this Angular Issue , you can use the following to create a dialog on the -change route, defer url change indefinitely (actually βundoβ the route change) and rewrite the URL string back to β/β without causing a reboot:
//Override normal $location with this version that allows location.skipReload().path(...) // Be aware that url bar can now get out of sync with what being displayed, so take care when using skipReload to avoid this. // From https://github.com/angular/angular.js/issues/1699#issuecomment-22511464 app.factory('location', [ '$location', '$route', '$rootScope', function ($location, $route, $rootScope) { $location.skipReload = function () { var lastRoute = $route.current; var un = $rootScope.$on('$locationChangeSuccess', function () { $route.current = lastRoute; un(); }); return $location; }; return $location; } ]); app .config(['$routeProvider', function ($routeProvider) { $routeProvider .when('/home', { controller: 'HomeCtrl', templateUrl: 'Home/HomeView.html' }) .when('/profile/:userId/changepwd', { template: ' ', controller: '', resolve: { data1: function($dialog, location, $q){ $dialog.messageBox(title, msg, btns) .open() .then(function(result){ //fires on modal close: rewrite url bar back to '/home' location.skipReload().path('/home'); //Could also rewrite browser history here using location? }); return $q.defer().promise; //Never resolves, so template ' ' and empty controller never actually get used. } } }) .otherwise({ redirectTo: '/' });
It looks like it runs without promises permission, and there may be a tidier solution, but it worked for my purposes.
source share