更改与$ routeChangeSuccess previous财产AngularJS位置/路由 [英] Change AngularJS location/route with $routeChangeSuccess previous property

查看:162
本文介绍了更改与$ routeChangeSuccess previous财产AngularJS位置/路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制器登录的保存这样的previous路线:

  $范围。在$('$ routeChangeSuccess',函数(事件,currentRoute,previousRoute){
  安全previousRoute = previousRoute。
});

所以我保存previousRoute在我厂的安全...

里面那个工厂,我需要使用改变我的位置!我该怎么办呢?
我试过:

 安全previousRoute.reload()。

但Route对象不具有重载方法...

感谢

我的previousRoute对象:

  | Ÿ{params:一个对象,pathParams:对象,$$路线:对象,loadedTemplateUrl:/app/template/user/index.html,reloadOnSearch:真的...}
  - $$路线:对象
  - loadedTemplateUrl:/app/template/user.html
  - params:一个对象
  - pathParams:对象
  - __proto__:对象


解决方案

只需使用$位置属性来设置网址

  $ location.path(安全previousRoute);

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

解决方案

Just use $location property to set the url

$location.path(security.previousRoute);

这篇关于更改与$ routeChangeSuccess previous财产AngularJS位置/路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆