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

angularjs中关于跨域设置白名单

时间:2018-04-17 15:41:41      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:hit   color   params   state   get   elf   lan   angularjs   href   

在config中注入$sceDelegateProvider服务使用resourceUrlWhitelist([])方法添加白名单

     跨域时将method的属性设置为"jsonp"就可以访问了

app.config(["$sceDelegateProvider",function($sceDelegateProvider){  
  
        $sceDelegateProvider.resourceUrlWhitelist([    <span style="white-space:pre;">      </span>//跨域添加白名单  
            "self",  
            "http://datainfo.duapp.com/**"  
        ]);  
   }  
]);  
$http({  
     method:"JSONP",  
     url:"http://datainfo.duapp.com/shopdata/getGoods.php",  
     params:{classID:$stateParams.classID}  
})  

参考:https://blog.csdn.net/qq_20343517/article/details/71090229

angularjs中关于跨域设置白名单

标签:hit   color   params   state   get   elf   lan   angularjs   href   

原文地址:https://www.cnblogs.com/soul-wonder/p/8866927.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!