Angular 2 CKEditor:编辑器实例已附加到提供的元素

时间:2016-05-09 12:35:11

标签: forms angular ckeditor

我正在使用此帖子Angular2 - CKEditor use的答案中解释的解决方案,但是我收到以下错误:

  

编辑器实例“editor1”已附加到提供的内容中   元件。

更新

ckeditor.ts

import {Component, Input} from "angular2/core";

@Component({
  selector: 'CKEDITOR',
  template: `
     <textarea name="targetId" id="targetId" rows="rows" cols="cols">
         This is my CKEditor component.
     </textarea>
  `
})
export class Ckeditor {

  @Input() targetId;
  @Input() rows = 10;  //you can also give default values here
  @Input() cols;

  constructor(){}
  ngOnInit(){
    window['CKEDITOR']['replace']( this.targetId );
  }
}

模板

 templateUrl: `<CKEDITOR [targetId]="editor1" [rows]="10" [cols]="80"></CKEDITOR>`,
  directives: [Ckeditor]

更新

我正在使用自定义ckeditor

  <script src="/ckeditor/ckeditor.js"></script>


  System.config({
      packages: {
        app: {
          format: 'register',
          defaultExtension: 'js'
        },
        "ng2-ckeditor": {
          "defaultExtension": "js"
        }
      }, map: {
        "ng2-ckeditor": "node_modules/ng2-ckeditor/lib/CKEditor.js"
      }
    });

0 个答案:

没有答案