0

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 class="row">
        <div class="col-md-6 col-lg-6 col-sm-12 text-center">
            <div class="bg-gray p-5 m-3" *ngIf="!editorStatus">
                <p class="mb-0">{{ htmlEditorValue }}</p>
            </div>

            <div class="htmleditor" *ngIf="editorStatus">
                <ckeditor name="htmlEditor" [config]="config" [editor]="Editor" [(ngModel)]="htmlEditorValue" skin="moono-lisa" language="en">
                </ckeditor>
                <button class="btn trans-btn list-head-btn ng-star-inserted btn-gradient mt-3 w-25" (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);
      }

And my output is: enter image description here

I recive a Raw HTML but i want HTML format. Anyone help me to fix this issue

1 Answer 1

2

Try setting your htmlEditorValue in .html file like this:

<p class="mb-0" [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%2Fapp%2Fapp.component.ts

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your response it's working :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.