直接上代码
1.优先使用第一种方式
$http.post(url,data).
success(function(res,status){
})
.error(function(res,status){
})
2.首先配置请求头
.config(function($httpProvider){
$httpProvider.defaults.headers.post = { 'Content-Type': 'application/x-www-form-urlencoded' }
})
然后在控制器里写
$http({
method:'post',
url:url, //请求url
data:opers //opers需要post的数据
}).success(function(req,status){
console.log(req,status);
})