更新时间:2022-06-17 07:14:48
store.filter
不查询服务器,它只是过滤存储中已经加载的数据。对于您而言,由于您一刻都不加载数据,因此过滤器将返回空结果。您可以调用 this.store.find('dish');
进行修复,以从服务器加载数据,因此,任何 filter('dish', ...)
将被更新。
store.filter
doesn't query the server, it just filter the already loaded data in the store. In your case because you don't load data in any moment, the filter will return a empty result. You can fix it calling this.store.find('dish');
to load data from the server, so any filter('dish', ...)
will be updated.
App.DishRoute = Ember.Route.extend({
model: function (param) {
console.log(param.dish_id);
// pre load the data
this.store.find('dish');
// filter the prefetch data, when update the filter when new data are loaded
return this.store.filter('dish', function(){return true;});
}
});
这是更新的jsbin http://jsbin.com/akeJOTah/1/edit
This is the updated jsbin http://jsbin.com/akeJOTah/1/edit
这是最常用商店的概述方法:
This is an overview of the most used store methods: