JustGoscha / allmighty-autocomplete

Simple to use autocomplete directive in a module for AngularJs!
MIT License
392 stars 232 forks source link

Fixing Bug #105

Open nasimmaleki opened 9 years ago

nasimmaleki commented 9 years ago

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); }; }]);