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

前端 未结 2 2048
一生所求
一生所求 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:05

    From the standpoint of the browser there is nothing special about angular - this is javascript, that's all that matters. So I would say the answer to your questions is - yes, it should work.

    Of course the constrains of the same origin policy will apply. Also asynchronicity may present some problems, but other than that it just should work

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题