title: AngularJS Execute function after a Service request ends
body: <p>I am using AngularJS Services in my application to retrieve data from the backend, and I would like to make a loading mask, so the loading mask will start just before sending the request. but how can I know when the request ends?</p>
  <hr />
  <p>For example I defined my servive as:</p>
  <pre><code>angular.module('myServices', ['ngResource'])
      .factory('Clients', function  ($resource) {
          return $resource('getclients');
      })
      .factory('ClientsDetails', function  ($resource) {
          return $resource('getclient/:cltId');
      })
  </code></pre>
  <p>So I use them in my controller as:</p>
  <pre><code>$scope.list = Clients.query();
  </code></pre>
  <p>and</p>
  <pre><code>$scope.datails = ClientsDetails.get({
      date:$scope.selectedId
  });
  </code></pre>
  <p>So the question would be, how to know when the <code>query</code> and <code>get</code> requests ends?</p>
  <hr />
  <h3>Edit:</h3>
  <p>As a side note in this question I've been using using angularjs <code>1.0.7</code></p>