Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.4K
Views
Angular, How to display text without the HTML tags?

I have a string stored in my localStorage with the HTML tags since I use ngx-quill (Angular Rich Text Editor) which stores the data in HTML formatted text.

This is what my localStorage looks like: enter image description here

As you can see from the picture above, in description, there is p tags.

Is there any way I can display it on Angular page without the tags? enter image description here

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You need to use innerHTML and make sure that you trust the HTML if it contains script tag else Angular will throw an error.

Do the following, create a safeHTML pipe:

import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';

    @Pipe({ name: 'sanitizeHtml' })
    export class SanitizeHtmlPipe implements PipeTransform {
    
        constructor(private sanitizer: DomSanitizer) { }
    
        transform(html: string): any {
            return this.sanitizer.bypassSecurityTrustHtml(html);
        }
    }

and then use this with innerHTML like this:

<span [innerHTML]="description" | sanitizeHtml"></span>
over 4 years ago · Santiago Trujillo Report

0

Use: [innerHTML] for that, for example:

<div [innerHTML]="data.description"></div>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!