javascript - location.path() AngularJS 方法中的重定向

标签 javascript angularjs rest spring-boot

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/

相关文章:

rest - 如何通过REST调用来存储应用程序的数据

javascript - Chrome 扩展 : Not allowed to load local resource

javascript - 如何使用 Javascript 将日期转换为自 1970 年以来的毫秒数?

angularjs - 模态 Controller 中的 $setValidity [AngularJS]

javascript - 如何监视函数中调用的属性?

.net - REST、HTTP 动词和 .NET 和 silverlight 中的当前开发

architecture - 在 REST 与 SOAP 服务之间进行选择的指南?

javascript - lytebox 中的关闭按钮

javascript - jquery选择和取消选择多个输入而无需ctrl单击

javascript - 将外部文件与 AngularJs 集成