Solution 1:

Wouldn't it be easier for you to just use an existing component such as https://github.com/ng-select/ng-select?

Highlighting matches is already implemented: https://ng-select.github.io/ng-select#/templates > Custom optgroup template.