Angularjs the IFRAME label NG-SRC path error Problem solving method
the SRC in the IFRAME is replaced directly with NG-SRC, and it needs to be converted. There is a property in angular that is specifically designed to solve cross-domain problems $sce.
PS:$SCE ($SCE service to turn some addresses into secure, authoritative links.) The common methods are:
$sce. Trustas (Type,name); $sce. trustashtml (value), $sce. Trustasurl (value), $sce. Trustasresourceurl (value); $ Sce.trustasjs (value);
$scope. Someurl = $sce. Trustasresourceurl (' path ');
举个栗子 >>
$scope. Httpsurl = $sce. Trustasresourceurl (' https://xxxx.xxxx.com/xxx/index.htm '); < ng-src= "{{$scope. Httpsurl}}" height= "100%" width= "100% "></iframe>
In order to use the aspect, hang in the filter inside
Angular.module (' app ', []). Filter (' Iframesrc ', [' $sce ', function ($SCE) { return function (val) { return $ Sce.trustasresourceurl (val); };}])
Html
<ng-src= "{{Someurl |iframesrc}}" height= "100%" Width= "100%"></iframe>
< 春风十里不如"你" -- 如果我爱"你" >
Angularjs the IFRAME label NG-SRC path error Problem solving method