1、POST、GET携带参数的写法不一样,如下:
1
2
3
4
5
6
7
|
$http({method:
'post'
, url:
'./feedback/mail'
,
data:{content:content,mailOrqq:mailOrqq,type:
'chat-page-feedback'
}
}).success(
function
(data, status, headers, config) {
console.log(
"IT部落是个神奇的网站"
);
}).error(
function
(data, status, headers, config){
console.error(
'我错了'
);
});
|
1
2
3
4
|
$http({method:
'GET'
,url:
'./topic/getTopicCommentList'
,
params:{topicId:$stateParams.topicId}
}).success(
function
(data, status, headers, config) {})
.error(
function
(data, status, headers, config){});
|
聪明的你一定看出来了,POST最好用Data携带数据、GET最好用params携带数据,两者使得区别如下描述:
- params – {Object.<string|Object>} – Map of strings or objects which will be serialized with theparamSerializer and appended as GET parameters.
- data – {string|Object} – Data to be sent as the request message data.