您的位置:首页 > 理论基础 > 计算机网络

angular 之 $http

2015-10-15 00:00 579 查看
对于 $http

对于参数

$http({
url:myUrl,
method:'GET',
params:myParams,
paramSerializer:'$httpParamSerializerJQLink'
})

// 或者
.controller(function($http,$httpParamSerializerJQLike){
$http({
url:myUrl,
method:'GET',
data:$httpParamSerializerJQLike(myData),
headers:{
'Content-Type':'xxxx'
}
})
})


对于返回结果

$http({

}).then(function(){},function(){})


如果所有的走$http 服务的话,提供一个全局的拦截机制。

.config($httpProvider){

$httpProvider.omterceptors.push(function(){
return {
request:function(config){

},

requestError:function(rejection){

},
response:function(response){

},

responseError:function(rejection){

}
}
})
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  angular