<h1><code ng:non-bindable="">linky</code>
<span class="hint">(filter in module <code ng:non-bindable="">ngSanitize</code>
)</span>
</h1>
<div><h2 id="Description">Description</h2>
<div class="description"><p>Finds links in text input and turns them into html links. Supports http/https/ftp/mailto and
plain email address links.</p></div>
<h2 id="Usage">Usage</h2>
<div class="usage"><h3 id="In.HTML.Template.Binding">In HTML Template Binding</h3>
<div class="in-html-template-binding"><code ng:non-bindable="">{{ linky_expression | linky }}</code>
</div>
<h3 id="In.JavaScript">In JavaScript</h3>
<div class="in-javascript"><code ng:non-bindable="">$filter('linky')(text)</code>
</div>
<h3 id="Parameters">Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">text – {string} – </code>
<p>Input text.</p></li>
</ul>
<h3 id="Returns">Returns</h3>
<div class="returns"><code ng:non-bindable="">{string}</code>
– <p>Html-linkified text.</p></div>
</div>
<h2 id="Example">Example</h2>
<div class="example"><h3>Demo Source Code</h3>
<div source-edit="ngSanitize" source-edit-deps="angular.js script.js" source-edit-html="index.html-203" source-edit-css="" source-edit-js="script.js-202" source-edit-unit="" source-edit-scenario="scenario.js-204"></div>
<div class="tabbable"><div class="tab-pane" title="index.html">
<pre class="prettyprint linenums" ng-set-text="index.html-203" ng-html-wrap="ngSanitize angular.js script.js"></pre>
<script type="text/ng-template" id="index.html-203">
  
  <div ng-controller="Ctrl">
  Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea>
  <table>
    <tr>
      <td>Filter</td>
      <td>Source</td>
      <td>Rendered</td>
    </tr>
    <tr id="linky-filter">
      <td>linky filter</td>
      <td>
        <pre>&lt;div ng-bind-html="snippet | linky"&gt;<br>&lt;/div&gt;</pre>
      </td>
      <td>
        <div ng-bind-html="snippet | linky"></div>
      </td>
    </tr>
    <tr id="escaped-html">
      <td>no filter</td>
      <td><pre>&lt;div ng-bind="snippet"&gt;<br>&lt;/div&gt;</pre></td>
      <td><div ng-bind="snippet"></div></td>
    </tr>
  </table>
</script>
</div>
<div class="tab-pane" title="script.js">
<pre class="prettyprint linenums" ng-set-text="script.js-202"></pre>
<script type="text/ng-template" id="script.js-202">
    function Ctrl($scope) {
      $scope.snippet =
        'Pretty text with some links:\n'+
        'http://angularjs.org/,\n'+
        'mailto:us@somewhere.org,\n'+
        'another@somewhere.org,\n'+
        'and one more: ftp://127.0.0.1/.';
    }
  </script>
</div>
<div class="tab-pane" title="End to end test">
<pre class="prettyprint linenums" ng-set-text="scenario.js-204"></pre>
<script type="text/ng-template" id="scenario.js-204">
  it('should linkify the snippet with urls', function() {
    expect(using('#linky-filter').binding('snippet | linky')).
      toBe('Pretty text with some links:&#10;' +
           '<a href="http://angularjs.org/">http://angularjs.org/</a>,&#10;' +
           '<a href="mailto:us@somewhere.org">us@somewhere.org</a>,&#10;' +
           '<a href="mailto:another@somewhere.org">another@somewhere.org</a>,&#10;' +
           'and one more: <a href="ftp://127.0.0.1/">ftp://127.0.0.1/</a>.');
  });

  it ('should not linkify snippet without the linky filter', function() {
    expect(using('#escaped-html').binding('snippet')).
      toBe("Pretty text with some links:\n" +
           "http://angularjs.org/,\n" +
           "mailto:us@somewhere.org,\n" +
           "another@somewhere.org,\n" +
           "and one more: ftp://127.0.0.1/.");
  });

  it('should update', function() {
    input('snippet').enter('new http://link.');
    expect(using('#linky-filter').binding('snippet | linky')).
      toBe('new <a href="http://link">http://link</a>.');
    expect(using('#escaped-html').binding('snippet')).toBe('new http://link.');
  });
</script>
</div>
</div><h3>Demo Source Code</h3>
<div class="well  doc-example-live" ng-embed-app="ngSanitize" ng-set-html="index.html-203" ng-eval-javascript="script.js-202"></div></div>
</div>
