diff --git a/package.json b/package.json index 63225dd..2031071 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng2-ckeditor", - "version": "1.2.9", + "version": "1.3.0", "description": "Angular CKEditor component", "main": "lib/bundles/ng2-ckeditor.umd.min.js", "typings": "lib/ng2-ckeditor.d.ts", diff --git a/src/ckeditor.component.ts b/src/ckeditor.component.ts index 5315a45..b69f7ae 100644 --- a/src/ckeditor.component.ts +++ b/src/ckeditor.component.ts @@ -12,6 +12,7 @@ import { ContentChildren, SimpleChanges, OnChanges, + OnDestroy } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { CKButtonDirective } from './ckbutton.directive'; @@ -35,7 +36,7 @@ declare var CKEDITOR: any; ], template: ``, }) -export class CKEditorComponent implements OnChanges, AfterViewInit { +export class CKEditorComponent implements OnChanges, AfterViewInit, OnDestroy { @Input() config: any; @Input() readonly: boolean; @Input() debounce: string; @@ -86,12 +87,14 @@ export class CKEditorComponent implements OnChanges, AfterViewInit { * On component destroy */ ngOnDestroy() { - if (this.instance) { - this.instance.removeAllListeners(); - CKEDITOR.instances[this.instance.name].destroy(); - this.instance.destroy(); - this.instance = null; - } + this.zone.runOutsideAngular( () => { + if (this.instance) { + CKEDITOR.removeAllListeners(); + CKEDITOR.instances[this.instance.name].destroy(); + this.instance.destroy(); + this.instance = null; + } + }); } /**