AngularJS使用$ route改变路线

时间:2013-05-16 08:07:05

标签: angularjs

我正在使用$ 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我设置来说明这一点。

0 个答案:

没有答案