title: AngularJS - Reading JSON from Factory, using result
body: <p>new to Angular and stuck on something that should be pretty easy...</p>
  
  <p>I have a few resources:</p>
  
  <pre><code>.factory( 'RSVPRes', function ( $resource )  {
    return {
      RSVP: $resource("../reservations/:id.json", {id:'@id'}, {'update': {method:'PUT'}, 'remove': {method: 'DELETE', headers: {'Content-Type': 'application/json'}}}),
      Meals: $resource('../meals.json'),
      UserInvites: $resource('../userinvite.json')
    };
  })
  </code></pre>
  
  <p>Meals.json:</p>
  
  <pre><code>[{"id":1,"name":"Chicken","description":"Chicken Yum!","created_at":"2013-12-11T22:37:28.994Z","updated_at":"2013-12-11T22:37:28.994Z","event_id":1,"event":{"name":"Wedding"}},{"id":2,"name":"Steak","description":"9oz","created_at":"2013-12-11T22:37:29.004Z","updated_at":"2013-12-11T22:37:29.004Z","event_id":2,"event":{"name":"Rehersal"}},{"id":3,"name":"Veggie","description":"Vegan","created_at":"2013-12-11T22:37:29.008Z","updated_at":"2013-12-11T22:37:29.008Z","event_id":3,"event":{"name":"Stag"}}]
  </code></pre>
  
  <p>UserInvites.json:</p>
  
  <pre><code>[{"id":18,"created_at":"2013-12-11T23:00:18.684Z","updated_at":"2013-12-11T23:00:18.684Z","event_id":1,"registry_id":1,"user_id":9,"total_in_party":2}]
  </code></pre>
  
  <p>Data seems to be formatted the same. All good here.</p>
  
  <p><em>EDITED</em> Now in my controller</p>
  
  <pre><code>.controller('RSVPCtrl', function RSVPController($scope, RSVPRes, $state, $stateParams) {
  
    //GET INVITATION(S)
    RSVPRes.UserInvites.query().$promise.then(function(response){
      $scope.invitation = response.data;
      //BUILD SELECT LIST FOR MEALS
      $scope.meals = RSVPRes.Meals.query();
  
      //EDIT
      if ($scope.rsvpId) {
        $scope.rsvp = RSVPRes.RSVP.get({id: $scope.rsvpId}, function() {
          // $scope.selectedUser = $scope.invite.user_id;
          // $scope.selectedEvent = $scope.invite.event_id;
          // $scope.selectedRegistry = $scope.invite.registry_id;
          // $scope.selectedTotalInParty =  $scope.invite.total_in_party;
        });
      }
      //NEW 
      else {
        //INITIALIZE EMPTY GUESTS
        $scope.guests = [];
        for (var i = 0; i &lt; $scope.invitation.total_in_party; i++) {
          $scope.guests[i] = {
            first_name: '',
            last_name: '',
            meal: 1,
            rsvp: 0
          };
        }
      }
    });
  
    $scope.submit = function() {
      for (var i = 0; i &lt; $scope.guests.length; i++){
         $scope.rsvp = new RSVPRes.RSVP();
         $scope.rsvp.first_name = $scope.guests[i].first_name;
         $scope.rsvp.last_name = $scope.guests[i].last_name;
         $scope.rsvp.meal_id = $scope.guests[i].meal;
         $scope.rsvp.rsvp = $scope.guests[i].rsvp;
         $scope.rsvp.$save();
      }
      $state.transitionTo('rsvps');
    };
  })
  </code></pre>
  
  <p>Inspecting my response.data I get my information, however my $scope.invitation is still undefined...</p>
  
  <p>Any help is much appreciated!</p>