Anupam Singh
Anupam Singh

Reputation: 11

Ckeditor set value to null after clear form

ckeEditorCommonConfig: any

ckeEditorCommonCongiguration(): void { this.ckeEditorCommonConfig = { height: "100%", extraPlugins: 'codeTag,kbdTag', removePlugins: "exportpdf", toolbar: [ { name: 'styles', items: ['Styles', 'Format'] }, { name: 'basicstyles', groups: ['basicstyles', 'cleanup'], items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', 'RemoveFormat', 'Code'] }, { name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi'], items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote'] }, { name: 'document', groups: ['mode', 'document', 'doctools'], items: ['Source'] }, ], toolbarGroups: [ { name: 'styles' }, { name: 'basicstyles', groups: ['basicstyles', 'cleanup'] }, { name: 'document', groups: ['mode', 'document', 'doctools'] }, { name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi'] }, ], removeButtons: "", language: 'en', forcePasteAsPlainText: false, allowedContent: true, extraAllowedContent: 'img', } }

In html file :

<ckeditor #ckeEditors [config]="ckeEditorCommonConfig" formControlName="comment" appEmptyToNull>

When I reset the form the value of ckediotr not set to null (this.commentForm.reset()) inside commentForm there is field called comment which is used to store ckeditor value.

After form reset the value to ckediotr not remove

Upvotes: 0

Views: 295

Answers (1)

JBoothUA
JBoothUA

Reputation: 3157

You would probably have to "bind" a variable to the 'data' property:

<ckeditor [editor]="Editor" data="<p>Hello, world!</p>"></ckeditor>

In this example above, you would bind a variable like this:

<ckeditor [editor]="Editor" data="{{ myVariable }}"></ckeditor>

Then in the .ts file you declare a public myVariable and set it to null

public myVariable: string = null;

Upvotes: 0

Related Questions