Angularjs 如何使用包装到CKEditor小部件中的Angular指令

Angularjs 如何使用包装到CKEditor小部件中的Angular指令,angularjs,widget,ckeditor,directive,Angularjs,Widget,Ckeditor,Directive,我们使用Angular指令将数据呈现到项目的CKEditor中。我已经创建了使用该指令作为模板的小部件,但它不会将任何内容呈现到字段中。请帮助! 提前谢谢你 小部件来源: CKEDITOR.plugins.add('grid', { requires: 'widget', init: function(editor) { editor.widgets.add('grid', { template: '<div class="widget"> <div

我们使用Angular指令将数据呈现到项目的CKEditor中。我已经创建了使用该指令作为模板的小部件,但它不会将任何内容呈现到字段中。请帮助! 提前谢谢你

小部件来源:

CKEDITOR.plugins.add('grid', {
requires: 'widget',
init: function(editor) {

    editor.widgets.add('grid', {
        template: '<div class="widget"> <div table-Directive></div> </div>',
        upcast: function(element) {
            return (element.name == 'div' && element.hasClass('widget'));
        },
        allowedContent: 'div[*]'
    });

    editor.ui.addButton('grid', {
        label: 'Demo',
        command: 'grid',
    });
}
编辑: 事实上,您可以在ckeditor中使用angular component,您只需要使用$compile自己编译它。 这里我附上简单的代码说明

// temporarily remove data-widget attribute sets by CKEditor before $compile()
// because angular thinks that data-widget is the same directive as widget
// and applies the directive twice
var dataWidget = element.getAttribute('data-widget');
element.removeAttribute('data-widget');
// use the scope of the closest parent that has a scope
var editorScope = $(editor.container.$).closest('.idoc-editor').isolateScope();
var compiledElement = application.$compile(element)(editorScope);
// $compile replaces the compiled element (instead of only decorating it)
// and this breaks the base CKEditor widget (this.element doesn't point to the
// correct element after $compile
this.element = new CKEDITOR.dom.node(compiledElement[0]);
this.element.$.setAttribute('data-widget', dataWidget);

我认为不能在ckeditor中插入angular js代码,ckeditor是在一个iframe中执行的,angular脚本不在这个iframe中加载


但是在ckeditor小部件中,您可以使用ajax请求与服务器进行交互

如果没有代码,就无能为力。添加了简单的代码
// temporarily remove data-widget attribute sets by CKEditor before $compile()
// because angular thinks that data-widget is the same directive as widget
// and applies the directive twice
var dataWidget = element.getAttribute('data-widget');
element.removeAttribute('data-widget');
// use the scope of the closest parent that has a scope
var editorScope = $(editor.container.$).closest('.idoc-editor').isolateScope();
var compiledElement = application.$compile(element)(editorScope);
// $compile replaces the compiled element (instead of only decorating it)
// and this breaks the base CKEditor widget (this.element doesn't point to the
// correct element after $compile
this.element = new CKEDITOR.dom.node(compiledElement[0]);
this.element.$.setAttribute('data-widget', dataWidget);