我正在使用$ routeChangeStart作为explained here实现身份验证检查,并寻找保留next
对象中提供的所有详细信息的方法。 AngularJS documentation on $route显示您可以设置$route.current
,我希望我执行以下操作来更改$route
而不是使用$location
:
$route.current = { templateUrl: 'detail.html', controller: 'MainCtrl' };
$route.reload();
我知道$ route.current可以更新,因为设置后console.log
显示它确实接收了更改:
console.log("current route: ", $route.current.templateUrl );
不幸的是它不起作用。我正在创建的应用程序具有使用$routeProvider
定义的其他参数,我想保留它。
有什么想法吗?
这是Plunker我设置来说明这一点。