How to remove html tags using filter in AngularJS ?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this post i will show you How to remove html tags by using filter in AngularJS ? Whenever you need to strip HTML tags by using Angular Filter, then i hope this post can help you. If we are working on php then we know it has a very easily use predefined function But when we are in AngularJS then we need to make our own filter for remove html tag from string.

So, now in bellow example you can see how to create it and also 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> 

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →