How to Remove HTML Tags from String in AngularJS?

By Hardik Savani November 5, 2023 Category : jQuery Angular

Hello Dev,

Here, I will show you angularjs remove html tags from string. I would like to show you remove html tags from string angularjs. you can understand a concept of angularjs strip tags filter. if you want to see an example of angularjs strip html tags then you are in the right place.

Whenever you require to strip HTML tags usign Angular Filter, then this post can help you. If you are working on php then it is very easily use predefine function But in AngularJS you need to make your own filter for remove html tag from string. So, In bellow example you can see how to create and use it.

Create Filter:

var app = angular.module('myHDApp', []);

app.filter('removeHTMLTags', function() {

return function(text) {

return text ? String(text).replace(/<[^>]+>/gm, '') : '';

};

});

Use Filter:

<p>{{ yourText | removeHTMLTags }}</p>

I hope it can help you...

Tags :
Shares