Is There a Way to Remove Html Tags from a String in Javascript? [Duplicate]

I am working with the rich text editor component of primeng. This editor turns everything i type in into html. But sometimes i want to output these texts in plain text instead. Does angular 2 provide a way to easily remove the html tags from the text?

Thank you.

0

You can achieve this by JavaScript.

Try this!!

var plainText = content.replace(/<[^>]*>/g, '');

This will return you plain text.

1
Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest