Is it possible to update angularjs expressions inside of an iframe?

前端 未结 2 2057
一生所求
一生所求 2020-12-09 13:17

So...for example, I am trying to pull in an email \"template\" into an iframe as a \"preview\" for the user inside of an angularjs app. The iframe lives inside of the contr

2条回答
  •  隐瞒了意图╮
    2020-12-09 14:06

    If you run the iframe and the parent document from the same domain name (so that no Cross-Site-Scripting-Restrictions apply) then you can call a JavaScript function in the iframe which you could pass data.

    What you might be missing is that the iframe is a separate document from the viewpoint of the browser. So if this iframe should run AngularJS code, you will need to make it a separate AngularJS application.

    Here is a example where both the parent document and the iframe are separate AngularJS applications and the value of a text input in the parent is sent upon change to the iframe where the AngularJS application running there will put the data into the scope.

    http://plnkr.co/edit/NZiKGZ9D99JyntLJ7Lxk

提交回复
热议问题