In setupController
, i have:
controller.set('products',
this.store.query('product', {
filter: { 'user-id': model.id },
page: { number: (params.page ? params.page : 1) }
})
);
Which returns:
{
"meta":{
"page":{
"number":1,
"size":10,
"total":17,
"prev":null,
"next":2,
"first":1,
"last":17
}
},
"data":[{..}, {..}]
}
In the template, why does {{log products.meta}}
return undefined
?
I do the same query in a model hook
and meta
actually returns valid data. Is there something special going on with setupController
?
What you're doing in your code is set the controllers products
property to the Promise returned from this.store.query
. You'll want to let that promise resolve before you set the property on the controller:
this.store.query('product', {
filter: { 'user-id': model.id },
page: { number: (params.page ? params.page : 1) }
}).then(products => {
controller.set('products', products);
});
That will make sure what you're actually assigning to the products
property is the resolved models, not the promise.