Achu
Achu

Reputation: 3

How to get value from entered in ckeditor using ngModel in angular 8?

<ckeditor [(ngModel)]="editorData" [editor]="Editor"></ckeditor>

How can i get the value of text inputted from ckeditor using ngmodel from html to component. I am using angular 8 and ckeditor 5

Upvotes: 0

Views: 4355

Answers (1)

C.OG
C.OG

Reputation: 6529

With ngModel

You'll already have the data in your component with 2-way binding. So the editorData property will have the most up-to-date value.

ckeditor ngModel

With change event

You can use the (change) event from the editor.

<ckeditor [editor]="Editor" (change)="onChange($event)"></ckeditor>
import { ChangeEvent } from '@ckeditor/ckeditor5-angular/ckeditor.component';

@Component( {
    // ...
} )
export class MyComponent {
    public onChange( { editor }: ChangeEvent ) {
        const data = editor.getData();

        console.log( data );
    }
    ...
}

ckeditor change

Upvotes: 2

Related Questions