1. 程式人生 > >解決angularjs使用iframe載入網址的跨域請求

解決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/**']);
});