简体   繁体   中英

Force angular to reload on any route/location change

Is there anyway to do this? That is, if I have a snippet such as:

$location.path("/splash");

Because I'm changing $location , angular will automatically reload the page (in order to reload all services/controllers). Basically my problem is that I have stale controller/service data being passed around that is messing my app up.

Obviously something like this is just causing the page to infinitely reload:

$rootScope.$on("$routeChangeSuccess", function(args){
   $route.reload();
});
  $scope.navTo = function(url) {
    if ($location.path() === url) {
      $route.reload();
    } else {
      $location.path(url);
    }
  }

(ui-router): $state.go($state.current.name, $state.params, { reload: true });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM