Browsers history back button problem on your SPA using AngularJS.
Have you been wearied by that history back button in your fav. browser? Don't worry there are ways to get the hang of it...
var myApp = angular.module(...
Execute this code in the run block:
myApp.run(function($rootScope, $route, $location){
//Bind the $locationChangeSuccess event on the //rootScope, so that we don't need to
//bind in induvidual controllers.
$rootScope.$on('$locationChangeSuccess', function() {
$rootScope.actualLocation = $location.path();
});
$rootScope.$watch(function () {
return $location.path()}, function (newLocation) {
if($rootScope.actualLocation === newLocation) {
// run a function or perform a reload
}
});
});
Written by Engr. Yhomhie™
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Tags
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#