Skip to content

Instantly share code, notes, and snippets.

@EpokK
Created May 23, 2014 06:27
Show Gist options
  • Save EpokK/934271b3904b089a20cd to your computer and use it in GitHub Desktop.
Save EpokK/934271b3904b089a20cd to your computer and use it in GitHub Desktop.
Pour bold une value dans une chaine via un filter AngularJS
.filter('bold', function() {
return function(str, object) {
return String(str).replace(new RegExp('(^|\\s)(' + object.value + ')(\\s|$)', 'ig'), '$1<b>$2</b>$3');
};
})
<div ng-bind-html="message | bold:{value:name}"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment