One way to accomplish this is by developing a custom filter.
In your script, define the controller and filter as follows:
var app = angular.module('app', []);
app.controller('mainCtrl', function($scope) {
$scope.sliderNote="This is my note";
$scope.selectedWords = ["This","note"];
});
app.filter("underline", function($sce){
return function(txt, phrase){
if(phrase instanceof Array){
if(txt === undefined){
return;
}
for (var i = 0; i < phrase.length; i++) {
var key = phrase[i];
txt = txt.replace(new RegExp('('+key+')', 'gi'),'<span style="text-decoration: underline;">$1</span>');
};
}
return $sce.trustAsHtml(txt);
};
});
In the view, make use of data-ng-bind-html like so:
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.j s"></script>
</head>
<body ng-controller="mainCtrl">
<div class="sliderNote" data-ng-bind-html="sliderNote | underscore : selectedWords">
</body>
</html>
Check out the Plunker example here: http://plnkr.co/edit/fLSzpvWwFXQaAs5dcjBf?p=preview