Paul
Paul

Reputation: 12819

Change AngularJS location/route with $routeChangeSuccess previous property

I have a controller Login that save the previous route like that :

$scope.$on('$routeChangeSuccess', function (event, currentRoute, previousRoute) {
  security.previousRoute = previousRoute;
});

So I save the previousRoute in my factory security...

Inside that factory I need change my location using that ! How can I do that? I tried that :

security.previousRoute.reload();

but that Route object does not have the reload method...

Thanks

My previousRoute object:

| y {params: Object, pathParams: Object, $$route: Object, loadedTemplateUrl: "/app/template/user/index.html", reloadOnSearch: true…}
 -  $$route: Object
 - loadedTemplateUrl: "/app/template/user.html"
 -  params: Object
 -  pathParams: Object
 -  __proto__: Object

Upvotes: 1

Views: 3324

Answers (1)

Ajay Singh Beniwal
Ajay Singh Beniwal

Reputation: 19037

Just use $location property to set the url

$location.path(security.previousRoute);

Upvotes: 2

Related Questions