Tag: 其余的

filter paginate将参数传递给异步ember数据关系请求

我想异步实现对ember数据的分页/过滤。 这是我的author模型: export default DS.Model.extend({ user: DS.belongsTo(‘user’), articles: DS.hasMany(‘article’, { async: true }), name: DS.attr(‘string’), email: DS.attr(‘string’) }); 路线: export default Ember.Route.extend({ model: function(params) { return this.store.find(‘author’, params.author_id); } }); 控制器: export default Ember.ObjectController.extend({ popularArticles: function() { return this.get(‘model.articles’).filter({ tab: ‘popular’ }); }.property(‘model.articles’) }); 请注意,模型具有带有DS.hasMany(‘article’, { async: true})关系的articles属性。 如果我使用此属性,则此请求将成为authors/1/articles及其异步。 这很好,直到我需要像authors/1/articles?page=2或authors/1/articles?tab=”hot”这样的请求。 一种可能的方法是,如控制器中所示,我有一个model.articles属性,用于过滤model.articles属性,并将生成过滤后的请求而不加载所有文章。 如何将查询参数传递给ember数据中的异步加载关系?