function HighlightFilter(LxUtils) {
        return function highlightCode(matchItem, query, html) {
            if (!html) {
                return (query && matchItem) ?
                    matchItem.replace(
                        new RegExp(LxUtils.escapeRegexp(query), 'gi'),
                        '<span class="lx-select-choices__pane-choice--highlight">$&</span>'
                    ) : matchItem;
            }

            var el = angular.element('<div>' + matchItem + '</div>');
            if (el.children().length) {
                angular.forEach(el.children(), function forEachNodes(node) {
                    if (node.nodeName !== 'SPAN') {
                        return;
                    }

                    var nodeEl = angular.element(node);
                    nodeEl.html(highlightCode(nodeEl.text(), query, false));
                });
            } else {
                el.html(highlightCode(el.text(), query, false));
            }

            return el.html();
        };
    }
Highlights text in a string that matches another string.

Taken from AngularUI Bootstrap Typeahead
See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L340