在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} }) 總結
以上所述是小編給大家介紹的關于Angularjs中跨域設置白名單問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對錯新站長站網站的支持!
新聞熱點
疑難解答
圖片精選