ember.js - Ember - Access Parent Model in a Child route Controller -
i want use both parent route's model, , child route's model child route. not sure "ember way" go this.
to little more specific:
the parent
the parent route has group model , has dynamic route groups/:group_id
the child
each group works on several units. in template group route above, list of units displayed, each link child route in question, groups/:group_id/unit/:unit_id. model route unit, set passing unit argument in link-to helper in parent route template.
the problem
the problem that, in addition unit model, need able access parent model - group, within groups/:group_id/unit/:unit_id route.
its 1 way relationship. while group has several units, other group might have number of units, can't use relationship.
i might set-up hash return both models in child route.js, model hook wouldn't executed if model passed via link-to. stuck on how this. or other way maybe access parent controller child controller, not sure correct way this.
thanks
it doesn't feel quite right, i've gotten around problem injecting parent controller.
i've gone in groups/:group_id/unit/:unit_id controller.
import ember 'ember'; export default ember.controller.extend({ groupcontroller: ember.inject.controller('groups.group'), group: ember.computed(function(){ return this.get('groupcontroller').get('model'); }), }); nevertheless feel there ought better way.
i'd like:
ideally, i’d reopen model in route, , hash parent model child model.
alternatively, i’d able access parent model child controller, in similar way modelfor in route.
either of these allow me make use of dynamic segments in url.
Comments
Post a Comment