-
-
Save alexspeller/6835814 to your computer and use it in GitHub Desktop.
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
// 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