Skip to content

Commit

Permalink
Merge pull request #28 from matiasah/patch-1
Browse files Browse the repository at this point in the history
Fix: The editor data is set to an empty string when the `ngModel` initializes or resets.
  • Loading branch information
ma2ciek authored Aug 28, 2018
2 parents ef1fceb + 41845d6 commit 9abe65d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ckeditor/ckeditor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue
}

// Implementing the ControlValueAccessor interface (only when binding to ngModel).
writeValue( value: string ): void {
writeValue( value: string | null ): void {
// If a null was received, the textarea content needs to be empty
if ( value == null ) {
value = '';
}
// If already initialized
if ( this.editorInstance ) {
this.editorInstance.setData( value );
Expand Down

0 comments on commit 9abe65d

Please sign in to comment.