title: Angular: How to create custom links around text strings using a filter
body: <p>I am working with a json feed about cars. Part of the text has [VIN:'vin_number_is_here']Car make model here[/VIN]. I am using this in an ng-repeat and would like to, unless there's a better way, use a filter to process the text and create a hyperlink to a custom function ending up with something like <code>&lt;a ng-click="modalViewCar('vin_number_is_here')"&gt;Car make model here&lt;/a&gt;</code></p>
  
  <p>I have the replacement of the [/VIN] done but am at a loss for how best to handle the opening "tag".** </p>
  
  <p>Additionally when I have hardcoded a test string I have found that the link never works which I assume is something Angular is responsible for...</p>
  
  <pre><code>app.filter('linkToVIN', ['$sce', function($sce) {
  return function(input) {
      input = input.replace("[/VIN]","&lt;/a&gt;");
      **input = input.replace("[VIN='12345abcdef']","&lt;a ng-click=\"modalViewCar('12345abcdef')\"&gt;");**
      return $sce.trustAsHtml(input);
  };
  </code></pre>
  
  <p>}]);</p>
  
  <pre><code>&lt;div ng-repeat="car in cars"&gt;
  &lt;div class="col-sm-12" ng-bind-html="car.details | filter:search | linkToVIN"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The VIN link is in the body of text. Sometimes multiple times. So each ng-repeat has a {{car.details}} which may, about 1 in 3 times, have at least one string with the [VIN] structure. What I'd really like to do is hot link those as they appear within the text as so far I have found a few outlier cases where there are references to other [VIN] numbers. E.g.</p>
  
  <blockquote>
    <p><em>Lorem ipsum dolor sit amet, [VIN:'12345abcdef']consectetur[/VIN] adipiscing elit. Vivamus laoreet odio nisi, eget gravida nunc porta gravida. Pellentesque nec porta tortor. In neque mi,[VIN:'000hijk']pretium[/VIN] at mattis ut, consectetur eget felis. Etiam tortor lacus, varius quis augue sed, condimentum varius massa.</em></p>
  </blockquote>
  
  <p>Which I would like to convert to. </p>
  
  <blockquote>
    <p>Lorem ipsum dolor sit amet, &lt; a ng-click="modalViewCar('12345abcdef')" >consectetur&lt; /a > adipiscing elit. Vivamus laoreet odio nisi, eget gravida nunc porta gravida. Pellentesque nec porta tortor. In neque mi,&lt; a ng-click="modalViewCar('000hijk')" >pretium&lt; /a > at mattis ut, consectetur eget felis. Etiam tortor lacus, varius quis augue sed, condimentum varius massa.</p>
  </blockquote>