Forms 通过表单输入字段传递AngularJS变量无效

Forms 通过表单输入字段传递AngularJS变量无效,forms,iframe,input,angularjs,field,Forms,Iframe,Input,Angularjs,Field,我有一个iFrame,它的内容位于不同的域中,我也可以控制它。我喜欢将机密数据从家长传递到iFrame。因此,我不想通过查询字符串或URL传递它。我喜欢通过表单隐藏的输入字段传递它。如果字段的值为文本,则该选项有效。但是,如果我使用AngularJS变量作为字段的值,它将不起作用 下面是我的代码 {{session.user.user_ID}} and {{i18n.domain}} works in this HTML file and writes the correct value

我有一个iFrame,它的内容位于不同的域中,我也可以控制它。我喜欢将机密数据从家长传递到iFrame。因此,我不想通过查询字符串或URL传递它。我喜欢通过表单隐藏的输入字段传递它。如果字段的值为文本,则该选项有效。但是,如果我使用AngularJS变量作为字段的值,它将不起作用

下面是我的代码

    {{session.user.user_ID}} and {{i18n.domain}} works in this HTML file and writes the correct values to the webpage.
    <form id="form_frame" action="http://other.mydomain.com/forIframe.php" method="post" target="output_frame">
        <input type="hidden" value="{{session.user.user_ID}}" name="id" />
        <input type="hidden" value="{{i18n.domain}}" name="domain" />
    </form>
    <iframe name="output_frame" width="400" height="400">
    </iframe>
    <script language="JavaScript" type="text/javascript"> 
        document.getElementById("form_frame").submit(); // automatically submit the form
    </script>
然而,上面写道:

user ID is: {{session.user.user_ID}}

为什么这个AngularJS变量不能正确解析到输入字段的value属性中?如何将{{session.user.user_ID}和{{i18n.domain}}中的值安全地传递给iFrame中的PHP文件?

iFrame中的元素不会继承父对象的作用域。您最好使用消息传递,即$broadcast和$on:

您的案例是否可以接受使用ngView?使用ngView,您可以将模板指定为外部HTML页面,在AngularJS应用程序中很好地发挥作用:@davidricitelli,当ng view指向other.mydomain.com/forIframe.php时,我在angular.js中的第5601行获得“RangeError:超出最大调用堆栈大小”。使用ng include时,不会显示任何内容。如果ng include指向www.mydomain.com上的一个文件,那么我仍然会遇到与以前相同的问题:“{{session.user.user_ID}}”被传递到PHP文件,而不是session.user.user_ID的值。谢谢,我欢迎任何其他建议。谢谢你的建议。我查看了链接上的代码。我不知道它是如何将AngularJS变量从www.domain.com传递到other.domain.com/forIframe.php的。你能指出代码是如何做到这一点的吗?
user ID is: {{session.user.user_ID}}