title: AngularJS return resource from service
body: <p>Everything works fine but I have problem getting source from service.</p>
  
  <p>I have SERVICE code below.</p>
  
  <pre><code>app.factory('myService', 
      function($rootScope, ResourceData) {
      var result = {};
      var data   = ResourceData.query();
  
      result.getData = function() {
          // problem here
      }
  
      return result;
  });
  </code></pre>
  
  <p>And CONTROLLER contain code.</p>
  
  <pre><code>app.controller('myController', ['$scope', 'myService', 
      function myController($scope, myService) {
         $scope.data = myService.getData();
  });
  </code></pre>
  
  <p>My problem is if I have function in my SERVICE like this </p>
  
  <pre><code>result.getData = function() {
     return data;
  }
  </code></pre>
  
  <p>Everything works fine but I need to filter that data before I get it</p>
  
  <p>If I change body like this I get an empty array the problem seems like it is from AngularJS.</p>
  
  <p>If I create static array it works.</p>
  
  <pre><code>result.getData = function() {
     var arr = [];
  
          angular.forEach(data, function(item, key) {
                // simple filter
                if(item.ID &gt; 10) {
                    return;
                }          
                else {
                    arr.push(item);
                }  
          });
  
          return arr;
  }
  </code></pre>