简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM