现在的位置: 首页 > 综合 > 正文

AngularJS:改变hash和route不完全重装controller

2014年10月23日 ⁄ 综合 ⁄ 共 369字 ⁄ 字号 评论关闭
var lastRoute = $route.current;
$scope.$on('$locationChangeSuccess', function(event) {
    $route.current = lastRoute;
});

..并确保$route注入过程中controller

但尽管如此,感觉就像DoNotFollowRoutesOnPathChange”是AngularJS缺少的功能

自从听了这个事件有效杀死$routeProvider
CONFIGS进一步使用我不得不这样限制为仅当前路径

var lastRoute = $route.current;
    if ($route.current.$route.templateUrl.indexOf('mycurrentpath') > 0) {
        $route.current = lastRoute;         
    }

抱歉!评论已关闭.