angular的http服务封装得并不完善,最好是自己做一个简单的封装
tempModule.factory('httpServer', function($http,$q) {
var service = {};
service.post = function (url,params,callback) {
var transform = function(data){
return $.param(data);
};
$http.post(url,params,{
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
transformRequest: transform
}).
success(callback);
};
return service;
});
使用时:
tempModule.controller("settingCtrl", ["$scope",'httpService', function ($scope,httpService) {
httpService.post(url,params,function(data){
//这里写你要做的事
})
}]);