在 Controller A 中,我执行 $location.path('/home')
,但实际上我想要一个正常的重定向。 $location.path 不会重新加载页面。我知道在 ui-route 中有 $state.go({reload:true})
,但是如何用普通的 ngRoute 做到这一点?我愿意
.controller('home', function($route){
$route.reload()
}
我有一个无限循环。
最佳答案
您可以使用窗口对象来重新加载,而不是$location.path('/path');
:
window.location = '/path';
如果你想使用ngRoute,你可以在routeChange上重新加载页面:
myApp.run(['$route', '$rootScope', function ($route, $rootScope) {
return $rootScope.$on('$routeChangeStart', function (event, next, current) {
$route.reload();
});
}]);
关于javascript - angularjs正常导航而不是$location.path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41185072/