Reputation: 981
I have two very similar routes:
App.DiscountRoute = Ember.Route.extend({
model: function() {
return Ember.RSVP.hash({
categories: this.store.findAll('discountCategory'),
discounts: this.store.findAll('discount'),
total_size: 6
});
}
});
and
App.CategoryRoute = Ember.Route.extend({
renderTemplate: function() {
this.render('discount');
},
model: function(params) {
return Ember.RSVP.hash({
categories: this.store.findAll('discountCategory'),
discounts: this.store.filter('discount',function(discount) {
return discount.get('discountCategory').get('id')==params.category_id
}),
total_size: 6
});
}
});
Where should I place categories model and total_size counter, which will be available from any routes in my application?
Upvotes: 1
Views: 51
Reputation: 8121
As @Kingpin2k pointed out in the comments, Application
route is probably your best bet for storing application-wide state info, since Application
route will always fire before the other routes. I believe this can be done in 1 of 2 ways.
application
model in other routes using modelFor('application')
needs
API as described hereUpvotes: 1