I am using angular CKEditor for HTML textarea. So I just get the value from CKEditor and show it to some other div. I have integrated this function using ngModel but I can't show the HTML form value. It's show the raw HTML value. Please check the below code and output.
HTML
<div >
<div >
<div *ngIf="!editorStatus">
<p >{{ htmlEditorValue }}</p>
</div>
<div *ngIf="editorStatus">
<ckeditor name="htmlEditor" [config]="config" [editor]="Editor" [(ngModel)]="htmlEditorValue" skin="moono-lisa" language="en">
</ckeditor>
<button (click)="getEditorValue()">Save</button>
</div>
</div>
</div>
TS
editorStatus: boolean = false;
htmlEditorValue = 'Test';
changeEditor() {
this.editorStatus = true;
}
getEditorValue() {
this.editorStatus = false;
console.log("ashok" this.htmlEditorValue);
}
I recive a Raw HTML but i want HTML format. Anyone help me to fix this issue
CodePudding user response:
Try setting your htmlEditorValue in .html file like this:
<p [innerHtml]="htmlEditorValue"></p>
Take a look here, if I understand your problem the right way, it should solve the problem: https://stackblitz.com/edit/angular-ivy-k7deuo?file=src/app/app.component.ts