hi, thanks for your useful lib.
I wanted to report you a bug. when I used your source I had a problem with the empty list and I got error from 'highlight' filter.Then I added a little change on the last if in your code.The new one is below :
app.filter('highlight', ['$sce', function ($sce) {
return function (input, searchParam) {
if (typeof input === 'function') return '';
if (searchParam) {
var words = '(' +
searchParam.split(/\ /).join(' |') + '|' +
searchParam.split(/\ /).join('|') +
')',
exp = new RegExp(words, 'gi');
if (words.length && input!=undefined) {
input = input.replace(exp, "<span class=\"highlight\">$1");
}
}
return $sce.trustAsHtml(input);
};
}]);
hi, thanks for your useful lib. I wanted to report you a bug. when I used your source I had a problem with the empty list and I got error from 'highlight' filter.Then I added a little change on the last if in your code.The new one is below : app.filter('highlight', ['$sce', function ($sce) { return function (input, searchParam) { if (typeof input === 'function') return ''; if (searchParam) { var words = '(' + searchParam.split(/\ /).join(' |') + '|' + searchParam.split(/\ /).join('|') + ')', exp = new RegExp(words, 'gi'); if (words.length && input!=undefined) { input = input.replace(exp, "<span class=\"highlight\">$1"); } } return $sce.trustAsHtml(input); }; }]);