Skip to content

Instantly share code, notes, and snippets.

@ravinsinghd
Last active September 13, 2016 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravinsinghd/488a058c034297a1f0c3134edb89905a to your computer and use it in GitHub Desktop.
Save ravinsinghd/488a058c034297a1f0c3134edb89905a to your computer and use it in GitHub Desktop.
Angular2 CK Editor component
import { Component, ViewChild, EventEmitter, Output} from '@angular/core';
@Component({
selector: 'ck-editor',
template: '<textarea class="editor" #editor></textarea>'
})
export class CKEditorComponent {
@Output() change = new EventEmitter();
@ViewChild('editor') editor;
editorInstance: any = {};
ngOnInit() {
}
ngAfterViewInit() {
this.editorInstance = CKEDITOR.replace(this.editor.nativeElement);
this.editorInstance.on('change', () => {
this.editorValueChanged();
})
}
editorValueChanged() {
let value = this.editorInstance.getData();
this.change.emit(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment