Get parent model for use in child controller


#1

Is there a sample showing how to get to the parent model for use in the child views. The requirement is to read filtered data in the parent model and display results as charts in the child views. Thanks for any suggestions and directions.


#2

Would controller needs property do what you’re looking for?

Controler.extend({
  needs : ['parentController'],
  parentContent : Ember.computed.alias('controllers.parentController.content')

#3

You need to let the Route handle this and don’t make any coupling between the controllers.

You say parent, so it should be something like this.

App.NotesNewRoute = Ember.Route.extend({
  setupController: function(controller, model) {
    controller.set('model', this.modelFor('notes'))
    this._super(controller, model)
  }
});