简体   繁体   中英

How can i render ngx-quill editor content from my database to a view component?

I'm working on an angular blog app that uses ngx-quill as a text editor. I had no trouble adding records to my database. the problem occurs when I try to render content, it's not showing the data.

this is my details-post component HTML where I want to show content:

 <article class="post" *ngIf="post$ | async as post; else loading"> <div class="post-thumbnail" style="background-image: url(&quot;https://images.unsplash.com/photo-1538370965046-79c0d6907d47?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80&quot;);" > <h1 class="post-title">{{ post.titlePost }}</h1> <div class="post-meta">February 20, 2020</div> </div> <div class="blog-post-content"> {{ post.contentPost }} </div> </article> <ng-template #loading> <div class="container-spinner"> <mat-spinner></mat-spinner> </div> </ng-template>

For ngx-quill you have to either use their own directive :

<quill-view [content]="content" format="text" theme="snow"></quill-view>

or innerHTML . More info here

<div class="ql-container ql-snow" style="border-width: 0;">
  <div class="ql-editor" [innerHTML]="byPassedHTMLString">
  </div>
</div>

I would suggest using their own directive.

Cheers

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