0

So, I'm using a route to hold state for 2 backend API calls. What I'm basically trying to do is:

App.EnvironmentRoute = Ember.Route.extend({
   model: function(params) {
     return this.store.find('schedule', params.environment_id);
   },

  setupController: function(controller, model) {
     this.controllerFor('schedule').set('content', model);
  },                                                                                                                                                                                                           

  renderTemplate: function() {
     this.render('schedule');
  },
});
App.ScheduleController = Ember.ArrayController.extend({});

This is the example with only one model loaded, though ultimately what I want to do is:

    App.EnvironmentRoute = Ember.Route.extend({
       model: function(params) {
          return Ember.RSVP.hash(
              schedule: this.store.find('schedule', params.environment_id),
              other: this.store.find('other', params.environment_id)
          }            
       },

       setupController: function(controller, models) {
          this.controllerFor('schedule').set('content', models.schedule);
          this.controllerFor('other').set('content', models.other);
       },   

(schedule - which is an array of models); what I want to achieve in the end is to delegate 2 backend calls to different controllers to different views/templates. The problem I currently have is even though I can see in the Chrome inspector the backend call being made and the data being returned properly, Ember.js doesn't seem to properly load it or set it into the ScheduleController. For what is worth I'm not even sure the data gets loaded into the model and I don't know how to verify that since the Route.model() method returns a promise.

I'm using ember 1.0.0 and ember-data 1.0.0-beta3.2

4

0 回答 0