Skip to content

Commit

Permalink
fix: reactive forms
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Jun 13, 2020
1 parent 980db5a commit bede7a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/ngx-editor.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Component, ViewChild, ElementRef,
forwardRef, OnDestroy, ViewEncapsulation, AfterViewInit
forwardRef, OnDestroy, ViewEncapsulation, OnInit
} from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';

Expand All @@ -22,7 +22,7 @@ import { NgxEditorService, NgxEditorServiceConfig } from './ngx-editor.service';
encapsulation: ViewEncapsulation.None
})

export class NgxEditorComponent implements ControlValueAccessor, AfterViewInit, OnDestroy {
export class NgxEditorComponent implements ControlValueAccessor, OnInit, OnDestroy {
@ViewChild('ngxEditor', { static: true }) ngxEditor: ElementRef;

private view: EditorView;
Expand Down Expand Up @@ -82,7 +82,7 @@ export class NgxEditorComponent implements ControlValueAccessor, AfterViewInit,

this.view.updateState(state);

if (tr.docChanged) {
if (tr.docChanged && this.onChange) {
const json = state.doc.toJSON();
this.onChange(json);
}
Expand All @@ -106,7 +106,7 @@ export class NgxEditorComponent implements ControlValueAccessor, AfterViewInit,
this.editorInitialized = true;
}

ngAfterViewInit() {
ngOnInit() {
this.createEditor();
}

Expand Down

0 comments on commit bede7a1

Please sign in to comment.