vendredi 28 juillet 2017

Ember - Access Parent Model in a Child route Controller

I want to use both a parent route's model, and the child route's model from the child route. Not sure the "Ember way" to go about this.

To be a little more specific:

The Parent

The parent route has a group model and has the dynamic route groups/:group_id

The Child

Each group works on several units. In the template for the group route above, the list of units is displayed, each with a link to the child route in question, groups/:group_id/unit/:unit_id. The model for this route is the unit, set by passing the unit as an argument in the link-to helper in the parent route template.

The problem is that, in addition to the unit model, I also need to be able to access the parent model - the group, from within the groups/:group_id/unit/:unit_id route.

I might set-up an hash to return both models in the child route.js, but the model hook wouldn't be executed if the model is passed via the link-to. Stuck on exactly how to do this.

Thanks




Aucun commentaire:

Enregistrer un commentaire