AngularJs主窗口和iframe窗口的模型相同 [英] AngularJs same model for main window and iframe window

查看:59
本文介绍了AngularJs主窗口和iframe窗口的模型相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

点击主窗口上的某些链接后,我试图打开一个新的iframe窗口.但是,我想使用相同的模型,即如果数据在主窗口中发生更改,则应将其反映在iframe中,反之亦然.主窗口用户界面将具有几个字段,而iFrame窗口将具有所有字段.

I am trying to open a new iframe window upon clicking some link on the main window. However, I would like to use the same model i.e if the data changes in main window, it should be reflected in iframe and vice versa. Main window UI will have couple fields whereas iFrame window will have all the fields.

我对angujar世界还很陌生,这可行吗?如果是,有什么建议吗?

I am pretty new to angujar world, is it doable? If yes, any suggestions?

推荐答案

不,您不能.新的iFrame在不同的上下文中运行.如果iFrame来自不同的域,则iFrame与父对象之间也存在安全限制.

No you cannot. The new iFrame is running in a different context. Also there is security restrictions between the iFrame and the parent if the are from different domains.

您可以做的是使用html5 postmessage在父级和iframe之间实现一个消息传递系统.您可以在主窗口中观察范围的更改,以将更改通知子对象并更新子范围.

What you can do is to implement a messaging system between the parent and the iframe using html5 postmessage. You can watch for changes on your scope in the main window notify the child of the changes and update the scope of the child.

这篇关于AngularJs主窗口和iframe窗口的模型相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆