Last active
September 13, 2016 10:21
-
-
Save ravinsinghd/488a058c034297a1f0c3134edb89905a to your computer and use it in GitHub Desktop.
Angular2 CK Editor component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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