title: AngularJS : How use $http in a filter
body: <p>I would like to do a request to my backend in a filter and return the result of my request.
  The problem is the service $http return a promise and it's the issue.</p>
  
  <p>For present the issue I used a $timeout and the promises of angular in my fiddle : 
  <a href="http://jsfiddle.net/flavien69/Kdeaa/">my fiddle</a></p>
  
  <p>In my filter I use a $timeout with a promise but the final goal is to use a request http :</p>
  
  <pre><code>myApp.filter('filterHello', function ($http,$timeout,$q) {
  return function (company_id) {
      console.log("in the filter");
      var deferred = $q.defer();   
      $timeout(function() {
          deferred.resolve("ca marche");
      }, 2000);                  
      return deferred.promise;
  };
  </code></pre>
  
  <p>});</p>
  
  <p>Then in my view I use my filter who is suppose to display "ca marche" with a delay of 2 secondes but that doesn't work : </p>
  
  <pre><code>&lt;div ng-controller="MyCtrl"&gt;
     {{hello|filterHello}}
  &lt;/div&gt;
  </code></pre>
  
  <p>You can see that the filter return nothing and that there is an infinite loop in the filter because of the null promise I think.</p>
  
  <p>If you don't understand why I want use a request http in a filter the answer is simple.
  For exemple I have an object user with the fields : email,name,company_id..
  And I have an other object company with the fields : name, createOn,... 
  I would like use the filter like this for display the name of the user's company :</p>
  
  <p>{{user.company_id | ShowNameCompany}} </p>
  
  <p>So, I need to do a request http in the filter to my company controller of my backend.</p>
  
  <p>I hope someone can help me.</p>