I've been cleaning up an external JSON URL feed that I am using, and I have successfully removed unnecessary special characters via a filter as so:
angularJS.filter('removeChar', function(){
return function(text) {
text = text.replace(/[[^]]+]/g, ''); // Characters inside Brackets
return text.replace(/;.*/, ''); // Characters after Colon
};
});
<span ng-bind-html-unsafe=item | removeChar>{{item}}</span>
However, what I am trying to achieve now - is to remove an ng-repeat item if it contains a specific string via a filter I can use.
For example:
<div ng-repeat=item in items | removeItem>{{item['flowers']}}</div>
If the item contains the word 'Red' or 'Green'
<div>Blue Roses</div>
<div>Red Roses</div>
<div>Orand and Green Roses</div>
<div>Yellow Roses</div>
<div>Red and Green Roses</div>
Only this will display from the ng-repeat with the filter:
<div>Blue Roses</div>
<div>Yellow Roses</div>
Help with an example would greatly be appreciated.
Thanks!
Roc.