How to remove html in angular js

Suppose you  have a textarea editor and you entered some text in it and making some formatting like change font or adding style etc . So now you want that when you are showing it you don't want to shown html you adding in it. See screenshot below.

Remove html in angular js

To do this below is a simple filter you can use : 

You just need to be add this filter in your app.js and change the "yourAppName" with your own.

yourAppName.filter('htmlToPlaintext', function() {
    return function(text) {
      return  text ? String(text).replace(/<[^>]+>/gm, '') : '';
Method of calling this filter :

<label style="color: #636363;">{{company.notes | htmlToPlaintext}}</label>

If you like this post don't forgot to leave a comment.

Happy Coding :)

Post a Comment

Previous Post Next Post