Angularjs the IFRAME label NG-SRC path error Problem solving method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.