<h1><code ng:non-bindable="">$filterProvider</code>
<span class="hint">(service in module <code ng:non-bindable="">ng</code>
)</span>
</h1>
<div><h2 id="Description">Description</h2>
<div class="description"><p>Filters are just functions which transform input to an output. However filters need to be Dependency Injected. To
achieve this a filter definition consists of a factory function which is annotated with dependencies and is
responsible for creating a the filter function.</p>

<pre class="prettyprint linenums">
  // Filter registration
  function MyModule($provide, $filterProvider) {
    // create a service to demonstrate injection (not always needed)
    $provide.value('greet', function(name){
      return 'Hello ' + name + '!':
    });

    // register a filter factory which uses the
    // greet service to demonstrate DI.
    $filterProvider.register('greet', function(greet){
      // return the filter function which uses the greet service
      // to generate salutation
      return function(text) {
        // filters need to be forgiving so check input validity
        return text && greet(text) || text;
      };
    };
  }
</pre>

<p>The filter function is registered with the <code>$injector</code> under the filter name suffixe with <code>Filter</code>.
<pre class="prettyprint linenums">
  it('should be the same instance', inject(
    function($filterProvider) {
      $filterProvider.register('reverse', function(){
        return ...;
      });
    },
    function($filter, reverseFilter) {
      expect($filter('reverse')).toBe(reverseFilter);
    });
</pre>

<p>For more information about how angular filters work, and how to create your own filters, see
<a href="guide/dev_guide.templates.filters">Understanding Angular Filters</a> in the angular Developer
Guide.</p></div>
<div class="member method"><h2 id="Methods">Methods</h2>
<ul class="methods"><li><h3 id="register">register(name, fn)</h3>
<div class="register"><p>Register filter factory function.</p><h4 id="Parameters">Parameters</h4>
<ul class="parameters"><li><code ng:non-bindable="">name – {String} – </code>
<p>Name of the filter.</p></li>
<li><code ng:non-bindable="">fn – {function} – </code>
<p>The filter factory function which is injectable.</p></li>
</ul>
</div>
</li>
</ul>
</div>
</div>
