我想使用AngularJS读取URL查询参数的值。我使用以下网址访问HTML:
http://demo.com/demo/demo.html?param1=125¶m=4
控制器:
App.controller( 'DrawsController', ['$scope','$q','$location','$http', function($scope,$q,$location,$http){
var deferred = $q.defer();
$http({
url: "./api/api.php",
method: "get",
dataType: "json",
params: {
param1: $location.param1,
param: $location.param
}
})
.success(function (data, status, headers, config) {
})
.error(function (data, status, headers, config) {
});
deferred.promise;
}]);

答案 0 :(得分:0)
var searchObject = $location.search();
var param1 = searchObject.param1;
var param = searchObject.param;