Replacing text using a filter

Cannot get my filter to work. I am trying to remove tags <br>and replace them with""

While I have it in my opinion:

<span ng-bind-html="description | stripbreaks"></span>

and my filter:

.filter('stripbreaks', function(text){
    return text.replace(/<br>/g, '');
});

but I get the following error: Unknown provider: textProvider <- text <- stripbreaksFilter

Is this the first time I have used my own filter so that everything I do wrong?

+4
source share
1 answer

You had the wrong syntax. Basically, an external functionfilter means dependency injection, and then the internal function is called in each digest cycle of the updated view.

: textProvider < - text < - stripbreaks - , text

.filter('stripbreaks', function(){
   return function(text){
      return text.replace(/<br>/g, '');
   }
});
+5

All Articles