这是我第一次尝试在AngularJS中使用$ location服务来检查查询字符串参数。我一直在阅读文档并试图在Plunkr中使用它来了解如何使用它,但到目前为止,我未能从查询字符串中检索任何参数。
我一直在使用测试它这个花掉http://plnkr.co/edit/RIFdWa5ay2gmRa6Zw4gm?p=info
var app = angular.module('myApp', [])
.config(function($locationProvider) {
$locationProvider.html5Mode(true);
});
angular.module('myApp').controller('myCtrl', function($scope, $location){
$scope.name = "Andrei";
$scope.url = $location.host();
$scope.path = $location.path();
$scope._params = $location.search();
});
我读过设置在$ locationProvider html5Mode(真),以获得$位置服务的“预期的工作是必需的“ - 我已经完成了,但是当设置这个时候,在我的普通模式中没有任何工作了(你可以将它设置为false,并且你会看到绑定再次正确)。
我错过了有关$ location服务的内容吗?
任何帮助或建议表示赞赏!
谢谢!
你Plunker不工作..对角1.3,你需要在你的HTML中加入碱标签..和之后,你的plunker是没有查询参数的iframe中(正如你所看到的路径不同于当前的URL路径) 我正在使用$ location.search()来获取url参数,它可以工作。 – 2014-10-30 13:42:10