app.js
.when('/ModifyStructure/{c}', {
templateUrl: 'views/ModifyStructure.html',
controller: 'ModifyStructureCTRL'
}
方法
$scope.editST = function (ids) {
var c = ids.substring(1, 3);
$location.path('http://localhost:8080/structure/ModifyStructure/' + c);
}
为什么执行此方法时,导航器将我重定向到“/”路径?
最佳答案
why when excuting this method , the navigator redirect me to the '/' path ?
因为您尝试设置的不是路径,而是绝对 URL。然而,在文档中它 explicitly states Angular 中的:
Path should always begin with forward slash (/), this method will add the forward slash if it is missing.
在您的情况下,由于路由配置中没有定义这样的路径,因此执行 otherwise
部分,我认为该部分已重定向到 /
。
您应该指定这样的路径:
$location.path('/ModifyStructure/' + c);
关于javascript - location.path() AngularJS 方法中的重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29582894/