Supplying two different models to a controller


Hi, I have CourseEnrollmentRoute and CourseEnrollmentController. This basically means I am trying to enroll certain users to a particular course. Thus, this route should have the users as its model. Here is the model hook of CourseEnrollmentRoute

model: function() {
        var users ="user"); }

I trainsition to this route, from the courses page, which has a list of courses. Thus I use tranisitionToRoute with the model as the particular course the user clicks on.

enrollCourse: function(params) {
			var course ="course", params);
			this.transitionToRoute("course.enrollment", course);

Now, in my CourseEnrollmentController, I can only see the Users model and cannot get the course model. I need the course model to fetch the courseid to do a POST.

What is the best way to access both these models in my enrollment controller?


Well you can use setupController on the Route

setupController: function(controller, model) {
  controller.set('model', this.modelFor(''))
  this._super(controller, model)

Here I need both models in my controller.


Thanks. That was exactly what I was looking for.