I’m porting an existing app to the new router api and can’t find an example where someone reaches into the router and grabs the apps store to query for data.
Here is my old router
CodeCamp.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
connectOutlets: function(router, context) {
router.get('applicationController').connectOutlet('sessions', router.get('store').findAll(CodeCamp.Session));
}
})
})
});
Here is the start to my new router but the “router.get(‘store’)” doesn’t like the word router and the keyword “this” also returns undefined.
CodeCamp.Router.map(function(match) {
match("/").to("sessions");
});
CodeCamp.SessionsRoute = Ember.Route.extend({
renderTemplates: function() {
this.render('sessions');
},
setupControllers: function() {
this.set('controller.content', this.get('store').findAll(CodeCamp.Session));
}
});
Update
I can get it to work with the following (it just seems ugly and I’d prefer another way)
setupControllers: function() {
this.set('controller.content', CodeCamp.Session.all().get('store').findAll(CodeCamp.Session));
}
Just use
CodeCamp.Session.find()😉