Skip to content

Instantly share code, notes, and snippets.

@James1x0
Created November 5, 2014 20:19
Show Gist options
  • Save James1x0/7c8c4e9b61404f3f382e to your computer and use it in GitHub Desktop.
Save James1x0/7c8c4e9b61404f3f382e to your computer and use it in GitHub Desktop.
Nested route behavior w/o view nesting
// router.js
Router.map(function () {
this.resource('employee', { path: 'employees/:id' }, function () {
this.route('index', { path: '/' });
this.route('edit');
});
this.resource('employee.dependent', { path: 'employees/:employeeid/dependents/:dependentid' }, function () {
this.route('index', { path: '/' });
this.route('edit');
});
});
// employee/dependent.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function ( params ) {
return this.store.find('employee', params.employeeid).then(function ( employee ) {
return employee.get('dependents').findBy('id', params.dependentid);
});
}
});
// {{#link-to 'employee.dependent' employee.id dependent.id}}{{/link-to}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment