# angular.filter.linky

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

## Description

Finds links in text input and turns them into html links. Supports http/https/ftp/mailto and plane email address links.

## Usage

### In HTML Template Binding

`{{ linky_expression | linky }}`

### In JavaScript

`angular.filter.linky(text)`

### Parameters

- `text – {string} –`

  Input text.

### Returns

`{string}` –

Html-linkified text.

## Example

        Snippet: <textarea name="snippet" cols="60" rows="3">
    Pretty text with some links:
    http://angularjs.org/,
    mailto:us@somewhere.org,
    another@somewhere.org,
    and one more: ftp://127.0.0.1/.</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="snippet | linky"&gt;<br/>&lt;/div&gt;</pre>
            </td>
            <td>
              <div ng:bind="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>

        it('should linkify the snippet with urls', function(){
          expect(using('#linky-filter').binding('snippet | linky')).
            toBe('Pretty text with some links:\n' +
                 '<a href="http://angularjs.org/">http://angularjs.org/</a>,\n' +
                 '<a href="mailto:us@somewhere.org">us@somewhere.org</a>,\n' +
                 '<a href="mailto:another@somewhere.org">another@somewhere.org</a>,\n' +
                 '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.');
        });