搜索设置高亮
(function(angular) { var app = angular.module('myApp', []); app.filter('highlight', ['$sce',function($sce) { var fn = function(input, search) { if(!input){ return ; } if (!search) { return $sce.trustAsHtml(input); } var regex = new RegExp(search, 'gi') var result = input.replace(regex, '<span style="background-color:yellow;">$&</span>'); return $sce.trustAsHtml(result); }; return fn; }]) })(angular)
<font ng-switch-default ng-bind-html="item[showColumns[$index].key] | highlight:search[showColumns[$index].key]"></font>