码迷,mamicode.com
首页 > Web开发 > 详细

angular 之 $http

时间:2015-10-15 13:05:00      阅读:354      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!