This.store.find(..) is not working in controller

I have two models say student,project. In MyRoute i set student as model so that i can get it in the MyController using "this.get('model')". But i want to get project details in MyController. How can i achieve this ? @tarasm 

What do you mean its not working?

What error are you getting?

Please, read this How to Report Bugs Effectively or something similar and respond with an answer that would help me help you.

 Nice one. Thanks. Ill follow before post a doubt or bug 

The simplest way is to make an additional request in your Route#setupController.


Ember.StudentRoute = Ember.Route.extend({
  setupController: function(controller, model) {
    // will perform the default behaviour which will load your controller with the model.
    this._super.apply(this, arguments);
    
    // perform your Ember Data query or other AJAX request
    this.store.find('project').then(function(result){
       // handle the result and load it into the controller
       controller.set('projects', result);
    }, function(error) {
       // handle the errors
    });
  }
});

2 Likes