があり、iframe
その内容はコントローラー関数にバインドする必要があります。私は試した
<iframe ng-bind-html-unsafe="selectedMessage.content()"></iframe>
しかし、残念ながらそれはうまくいかないようです。にコンテンツを書き込む正しい方法は、 DOM 要素にiframe
アクセスしてを呼び出すことです。iframe
ifrmElem.contentDocument.write(s)
どうすればこれを達成できますか?
があり、iframe
その内容はコントローラー関数にバインドする必要があります。私は試した
<iframe ng-bind-html-unsafe="selectedMessage.content()"></iframe>
しかし、残念ながらそれはうまくいかないようです。にコンテンツを書き込む正しい方法は、 DOM 要素にiframe
アクセスしてを呼び出すことです。iframe
ifrmElem.contentDocument.write(s)
どうすればこれを達成できますか?
これを実現するには、プロパティにウォッチャーを設定し、必要に応じてiframeを手動で更新します。
以下の例では、クロスブラウザーのiframeコンテンツ選択を使用しています。
jsFiddleを参照してください:http://jsfiddle.net/uyLNY/2/
$scope.$watch('data.content', function(oldValue, newValue) {
var ifrm = $element.find('iframe')[0];
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write(newValue);
ifrm.document.close();
});
ただし、大量のコンテンツを作成する場合、これのパフォーマンスはわかりません。
ここに plnkr があります: http://plnkr.co/edit/LG7p1AG7yhVKyLXgMX4Q?p=preview
Javascript
$scope.content= "";
$scope.fillFrame = function(id) {
document.getElementById(id).contentDocument.write($scope.content);
};
HTML
<strong>Enter some html</strong>
<br/>
<textarea ng-model="content"></textarea>
<button ng-click="fillFrame('frame')">Fill iFrame</button>