请问我怎样才能为每个产品过滤一组项目?或者如何过滤包含类别数据的项目?
var Categories = new Backbone.Collection();
Categories.add([
{ title: 'category 1', category_type: 'category 1' },
{ title: 'category 2', category_type: 'category 1' },
]);
var Items = new Backbone.Collection();
Items.add([
{ title: 'Product 1', category: 'category 1' },
{ title: 'Product 2', category: 'category 1' },
{ title: 'Product 3', category: 'category 2' }
]);
var byFiltred = Items.groupBy('category');
var filtred = new Backbone.Collection(byFiltred['category 1']);
console.log(filtred.pluck('title'));
感谢您的意见和回答!马克罗马特