title: angularjs service not working as expected
body: <p>I have this service:</p>
  
  <pre><code>angular.module('autotestApp').factory('GroupService', ['$http', function ($http) {
      var groups = [];
  
      return{
          list: function () {
              return groups;
          },
          retrieve: function () {
              $http({
                  method: "get",
                  url: "/enterprises/_groups"
              }).success(function (response) {
                  groups = response;
              }).error(function () {
                  console.log("failed")
              });
          }
      }
  }]);
  </code></pre>
  
  <p>and this is my controller:</p>
  
  <pre><code>angular.module('autotestApp').controller('GroupsController', function($scope, $http, GroupService) {
      GroupService.retrieve();
      $scope.items = GroupService.list();
  });
  </code></pre>
  
  <p>So, in my controller, I am first getting the result from the API so that the variable groups(in the service) gets assigned, then I am using the list() method to assign the values to $scope.items.</p>
  
  <p>I am sure that API is returning results. But the </p>
  
  <pre><code>groups = response
  </code></pre>
  
  <p>part is not working correctly. When I changed it to</p>
  
  <pre><code>groups.push(response)
  </code></pre>
  
  <p>it is working but the result is a list inside a list, which I dont't want: [[ Object, Object, Object ]] </p>
  
  <p>I want this: [ Object, Object, Object ]</p>
  
  <p>How to fix this?</p>