Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Forked from anonymous/router.js
Last active December 24, 2015 17:29
Show Gist options
  • Save alexspeller/6835814 to your computer and use it in GitHub Desktop.
Save alexspeller/6835814 to your computer and use it in GitHub Desktop.
// For more information see: http://emberjs.com/guides/routing/
App.Router.map(function() {
this.resouce('plan', function() {
this.resource('projects', function() {
this.resource('project', {path: ':project_id'})
});
});
});
App.PlanRoute = Ember.Route.extend({
model: function() {
return Em.RSVP.hash({
projects: this.store.find('project'),
somethingElses: this.store.find('somethingElse')
},
setupController: function(controller, context) {
// not setting anything to controller passed in (which will be PlanController)
// this is because there doesn't seem to be a plan model. If there is, add it to the hash
// and set it's model here
this.controllerFor('projects').set('model', context.projects);
this.controllerFor('somethingElses').set('model', context.somethingElses);
}
});
App.PlanController = Em.Controller.extend({
needs: ['projects', 'somethingElses']
projectsCount: Em.computed.alias('controllers.projects.length'),
somethingElsesCount: Em.computed.alias('controllers.somethingElses.length'),
});
App.ProjectsController = Em.ArrayController.extend()
App.SomethingElsesController = Em.ArrayController.extend()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment