How can I mark my search pattern dynamically in my html?
Example:
I\'m using angular
Inspired by @tungd's answer but valid for multiple search terms.
.filter('highlight', function($sce) {
return function(text, phrase) {
if (phrase){
phrases = phrase.split(" ");
for(i=0;i');
text = text.replace(new RegExp('('+'%%%%%'+')', 'gi'),'')
}
return $sce.trustAsHtml(text)
}
});
PS: One can always limit the input to be in non-special chars for this to be 100% bullet-proof.