category
有多个products
。如何收集products
几个categories
?此代码不起作用:
controller.js
selectedCategories: Ember.computed.filter('model.categories', function(model.categories, index) {
return (index < 10);
}).property('model.categories'),
productsOfSelectedCategories: Ember.computed('selectedCategories', 'model.products', function() {
var selectedCategories = this.get('selectedCategories');
var products;
productsOfSelectedCategories.map((category) => {
products.push(category.products);
})
return products;
}),
route.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return {
categories: this.store.find('category'),
products: this.store.find('product'),
};
}
});