Hi,
I have a router (eg products) where I want to determine dynamically, based on the response of the json api, whether to display a listing of categories or items.
In my router I have a property
isCategories:false
and in the model hook something like this, where I want to be able to change the isCategories property depending on the value returned from the api call - true/false
model() {
Ember.$.post('/api/products/showCategoriesOrItems').then(function(answer) {
// I can't use this.set('isCategories',true) for example
});
}
What I then want to do is return the model depending upon the revised value of isCategories so something like
if (this,get('isCategories')) {
return this.store.findAll('product-category');
}
else {
return this.store.findAll('product')
}
Any help much appreciated!