關於AngularJs中$http post、get 發送和接受參數詳解app
$http({method: 'post', url: './feedback/mail',post
data:{content:content,mailOrqq:mailOrqq,type:'chat-page-feedback'}網站
}).success(function(data, status, headers, config) {url
console.log("IT部落是個神奇的網站");
}).error(function(data, status, headers, config){code
console.error('我錯了');get
});string
$http({method: 'GET',url:'./topic/getTopicCommentList',it
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.io