I found that the manual does not provide such a method for get?
阿神2017-05-15 16:52:21
What you mean by bringing JSON is to pass JSON parameters to the backend in RequestBody, right?
If this is the case, then you are thinking wrong. It’s not that Angular doesn’t provide it, but that you shouldn’t do it
怪我咯2017-05-15 16:52:21
HTTP GET
方法不支持传body
域,如果你指的是将JSON
通过参数传递的话应该先将JSON
进行URLEncode
, that is:
var data = {'foo': 'bar'};
var json_str = JSON.stringify(data);
var encoded_param = encodeURIComponent(json_str); // 转码
$http.get('/path', {
params: { encoded_param: userencoded_paramid }
});
The words passed through Angular $http
should be
淡淡烟草味2017-05-15 16:52:21
angular.module('ngApp')
.controller('aboutCtrl', function ($scope, $http) {
var url = 'xxx.json';
$http.get(url).success(function (data) {
$scope.tableDate = data
})
});