[英]AngularJS directive for updating IFrame's body
我想將模型屬性綁定到iframe的主體。
使用jQuery,邏輯必須寫成類似的東西
$('iframe').contents().find('body').html('<p>Hello</p>');
理想情況下,我希望AngularJS指令類似於..
<myframe body="model.safehtml"></myframe>
誰能指出我正確的方向?
謝謝
您可以在Angular 指令的link
函數中更改DOM。
app.directive('myframe', function($compile) {
return {
restrict: 'E',
scope: {
body: '='
},
template: "<iframe></iframe>",
link: function(scope, elm, attrs) {
elm.find('iframe').contents().find('body').html(scope.body);
}
};
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.