AngularJS Highlight Filter

An AngularJS filter for highlighting and editing text parts on the view side with a regex.
I used this filter for linking twitter hashtags on a project of mine.

Download source - Demo page

Example

Original text

Filtered text / Result

need to be updated


Usage

  1. Include "highlight.filter.js" in the html head
  2. Edit the highlight filter app name based on your angular module app name (default name is set to 'app')
  3. Use the filter in a ng-bind-html if you want to highlight text with anchors
<html ng-app="app"> 
<head>
    ...template, angular stuff, etc...

    <!-- include the filter -->
    <script src="highlight.filter.js"></script> 

    ....
</head>
<body>
    <div ng-controller="main">
        ...
        <span ng-bind-html="text | highlight"> content</span>
        ...        
    </div>
</body>

</html>