Javascript 用于更新IFrame&x27的AngularJS指令;身体

Javascript 用于更新IFrame&x27的AngularJS指令;身体,javascript,angularjs,iframe,angularjs-directive,Javascript,Angularjs,Iframe,Angularjs Directive,我想将模型属性绑定到iframe的主体 使用jQuery,逻辑必须编写如下内容 $('iframe').contents().find('body').html('<p>Hello</p>'); $('iframe').contents().find('body').html('Hello'); 理想情况下,我希望AngularJS指令类似于 <myframe body="model.safehtml"></myframe> 谁能给我指出

我想将模型属性绑定到iframe的主体

使用jQuery,逻辑必须编写如下内容

$('iframe').contents().find('body').html('<p>Hello</p>');
$('iframe').contents().find('body').html('Hello

');
理想情况下,我希望AngularJS指令类似于

<myframe body="model.safehtml"></myframe>

谁能给我指出正确的方向吗


谢谢

您可以在角度传感器的
链接
功能中更改DOM

app.directive('myframe',函数($compile){
返回{
限制:'E',
范围:{
正文:'='
},
模板:“”,
链接:功能(范围、elm、属性){
elm.find('iframe').contents().find('body').html(scope.body);
}
};
});
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);
    }
  };
});