title: AngularJS filter returning html as string
body: <p>I've created an AngularJS filter to automatically create clickable links from addresses found in data. The filter:</p>
  
  <pre><code>app.filter('parseUrl', function() {
      var  //URLs starting with http://, https://, or ftp://
          replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/gim,
          //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
          replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim,
          //Change email addresses to mailto:: links.
          replacePattern3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim;
  
          return function(text, target, otherProp) {        
              angular.forEach(text.match(replacePattern1), function(url) {
                  text = text.replace(replacePattern1, "&lt;a href=\"$1\" target=\"_blank\"&gt;$1&lt;/a&gt;");
              });
              angular.forEach(text.match(replacePattern2), function(url) {
                  text = text.replace(replacePattern2, "$1&lt;a href=\"http://$2\" target=\"_blank\"&gt;$2&lt;/a&gt;");
              });
              angular.forEach(text.match(replacePattern3), function(url) {
                  text = text.replace(replacePattern3, "&lt;a href=\"mailto:$1\"&gt;$1&lt;/a&gt;");
              });
  
              return text;        
          };
      });
  </code></pre>
  
  <p>And here is how I'm calling it (inside a paragraph):</p>
  
  <pre><code>&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt; {{event.description | parseUrl}}&lt;/p&gt;
  </code></pre>
  
  <p>And this works correctly to replace the plain text links with the code for a link. However, it replaces it with the link literally as plain text. For example, <code>www.google.com</code> would get replaced with <code>&amp;lt;a href="http://www.google.com" target="_blank"&amp;gt;http://google.com&amp;lt;/a&amp;gt;</code>. This clearly doesn't make a clickable link, which was my goal.</p>
  
  <p>I'm not sure why this is happening. Any ideas on how to prevent/fix it? Thanks.</p>