原 controller :angularjs
$scope.myURL = URL;url
頁面:.net
<iframe ng-src='{{myURL}}' class="width-100 height-100"></iframe>get
發現頁面不能打開 <iframe> 中的內容。iframe
如今將 controller 中改寫以下 便可:class
$scope.myURL = $sce.trustAsResourceUrl(URL); //URL 爲全連接($sce.trustAsResourceUrl("http://" + url))angular
trustAsResourceUrl 是 AngularJS 中防止用戶注入 URL 的方法。rust