title: AngularJS Controller wait for response (or set callback)
body: <p>I have a AngularJS application with a controllers.js and factories.js.</p>
  
  <p>What I like is to do something with the values in the controller (which I get from the factories). My problem is, that these values are empty at the time I access them.</p>
  
  <p>How can I wait for the response? Or where can I add a callback?</p>
  
  <pre><code>    Flashcards.controller('CardDeckDetailController', function($scope, $routeParams, CardDeckService, CardService) {
      $scope.carddeck = CardDeckService.findCardDeckByID($routeParams.cardDeckID);
      $scope.cards = CardService.findCardsByCardDeckID($routeParams.cardDeckID);
      $scope.card = $scope.cards[0];
      $scope.cardLength = $scope.cards.length;
  
  });
  
      Flashcards.factory('CardDeckService', function($resource) {
      var cardDeckService = $resource('/FlashcardsServer/rest/carddecks/:cardDeckID', {}, {});
  
      cardDeckService.findAllCardDecks = function() {
          return cardDeckService.query();
      };
  
      cardDeckService.findCardDeckByID = function(id) {
          return cardDeckService.get({ cardDeckID : id });
      };
  
      return cardDeckService;
  });
  </code></pre>
  
  <p>What I like is to get the first car ($scope.cards[0]) and save it under $scope.card. But its always empty (same with cardsLength).</p>
  
  <p>On the other hand if I print out the size from the partial view with (cards.length), I get the correct value.</p>
  
  <p>Greets and Thanks
  Marc</p>