首页 > Web开发 > 详细

angular 之 $http

时间:2015-10-15 13:02:43      阅读:301      评论:0      收藏:0      [点我收藏+]

对于 $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 之 $http

原文:http://my.oschina.net/bosscheng/blog/517463

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!