Created
November 5, 2014 20:19
-
-
Save James1x0/7c8c4e9b61404f3f382e to your computer and use it in GitHub Desktop.
Nested route behavior w/o view nesting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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