I use the new deferIntercept () ui-router to update the browser url without rebooting my controller:
$rootScope.$on('$locationChangeSuccess', function(e, newUrl, oldUrl) { e.preventDefault(); if ($state.current.name !== 'search') { $urlRouter.sync(); } $urlRouter.listen(); });
Using this code, clicking on the browser return button changes the URL to the previous one, but I cannot update my controller state to reflect this change. $ stateParams still contains the values set when the user first loads the page.
What is the best way to update the $ state and $ stateParams objects inside my controller when the user clicks the back button or manually changes the URL?
thanks!
javascript angularjs angular-ui-router
Simon watiau
source share