I have a model hook in my Route object that looks like this:
model: function(params) {
// return an active filter for activities on given date
return this.store.filter('activity',function(activity){
var itemDate = new Date(activity.get('start_time'));
itemDate = moment(itemDate).format('YYYY-MM-DD');
return itemDate === params.on_date;
});
}
The route's currentModel gets populated with the DS.FilteredRecordArray with all the appropriate values set but for some reason the model never gets passed to the controller and therefore my template's {{#each}} {{/each}} remains empty.
I created a hack where I set added the following to the route:
setupController: function(controller, model) {
controller.set('model',this.get('currentModel'));
}
This actually works when you load the controller the first time but then goes into an infinite loop when you transitionTo to the route. Ahh well, it was a hack anyway. Does anyone know how I can get this working the "Ember way"?
currentModel? - choppercurrentModelexplicitly. I just assumed this was part of the Ember dark arts. I simply return an object from themodelhook in the Route and currentModel gets populated (with what I'd expect to be in themodelproperty. - kensetupControllerfunction as a parameter. Thus all you should need to do iscontroller.set('content', model);. I'll also add that as an answer - let me know if that works for you. - chopper