Created
May 23, 2014 06:27
-
-
Save EpokK/934271b3904b089a20cd to your computer and use it in GitHub Desktop.
Pour bold une value dans une chaine via un filter AngularJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.filter('bold', function() { | |
return function(str, object) { | |
return String(str).replace(new RegExp('(^|\\s)(' + object.value + ')(\\s|$)', 'ig'), '$1<b>$2</b>$3'); | |
}; | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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