所以我想在函数内使用$ location.path来更改AngularJS中的路由位置,但它不起作用。从函数中更改路由位置
app.controller('globalCtrl', function($scope, $route, $location){
$scope.changePath = function(newPath){
$location.path(newPath);
};
$scope.changePath("/login");
}
我应该如何调用函数或我该怎么做?
为什么要检查'location'?是否用于检查当前路线? –
我不想检查它,我想改变它 –
所以使用'$ location.path(newPath)' –