0

私が管理している別のドメインのコンテンツを持つ 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>

これは、iFrame のコンテンツを書き込むファイルである forIframe.php ファイルにあります。

echo 'user ID is: '.$_POST['id'];

ただし、上記には次のように書かれています。

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

この AngularJS 変数が入力フィールドの値属性に正しく解析されないのはなぜですか? {{session.user.user_ID}} と {{i18n.domain}} の値を iFrame の PHP ファイルに安全に渡すにはどうすればよいですか?

4

1 に答える 1

0

iFrame 内の要素は、親のスコープを継承しません。メッセージング、つまり $broadcast と $on を使用することをお勧めします: http://plnkr.co/edit/Osa5MNKiJKzsi7wAUXgM?p=preview

于 2013-06-03T03:55:13.400 に答える