解決angularjs使用iframe加載網址的跨域請求

<iframe  ng-src="{{url}}" width="100%" height="100%" seamless frameborder="0" ></iframe>

打開不同域的內容時報下面的錯誤:
Blocked loading resource from url not allowed by $sceDelegate policy

 

app.config(function($sceDelegateProvider) {
   $sceDelegateProvider.resourceUrlWhitelist([
       // Allow same origin resource loads.
       'self',
       // Allow loading from our assets domain.  Notice the difference between * and **.
       'http://media.w3.org/**']);
});

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章