Ember.js Ember js从模型中筛选数据

Ember.js Ember js从模型中筛选数据,ember.js,filter,Ember.js,Filter,我试图从余烬模型中筛选数据,但我无法找到解决方案 该文件位于app/routes/notes.js中 文件为app/templates/note.hbs 我想根据模板上的状态和显示过滤输出。但是我无法修改数据,它显示了一些错误。我尝试过从模型本身或控制器操作中进行过滤,但不起作用。有人能推荐解决方案吗?只过滤一次: model() { return this.store.findAll('note').then((data) => { return data.filter(({

我试图从余烬模型中筛选数据,但我无法找到解决方案

该文件位于app/routes/notes.js中 文件为app/templates/note.hbs 我想根据模板上的状态和显示过滤输出。但是我无法修改数据,它显示了一些错误。我尝试过从模型本身或控制器操作中进行过滤,但不起作用。有人能推荐解决方案吗?

只过滤一次:

model() {
  return this.store.findAll('note').then((data) => {
    return data.filter(({ status }) => status === 'HELLO');
  }); // see ES6 Promise specification for .then
}
动态服务器端筛选:

// route.js
queryParameters: {
  status: { refreshModel: true }
},
model({ status }) {
  return this.store.query('note', { status: status });
}

// controller.js
queryParameters: ['status']

status: 'HELLO'

// e.g. user could change 'status' using dropdown
// route.js
model() {
  return this.store.findAll('note');
}

// controller.js
selectedStatus: 'SOME',
filteredModel: computed('model.length', 'selectedStatus', function() {
  return this.get('model').filterBy('status', this.get('selectedStatus'));
})
动态客户端筛选:

// route.js
queryParameters: {
  status: { refreshModel: true }
},
model({ status }) {
  return this.store.query('note', { status: status });
}

// controller.js
queryParameters: ['status']

status: 'HELLO'

// e.g. user could change 'status' using dropdown
// route.js
model() {
  return this.store.findAll('note');
}

// controller.js
selectedStatus: 'SOME',
filteredModel: computed('model.length', 'selectedStatus', function() {
  return this.get('model').filterBy('status', this.get('selectedStatus'));
})

问题1:您的有效负载是否返回您需要的信息?问题2:您是否能够看到有效负载返回到余烬数据中?(您可以使用Ember Inspector插件进行检查)问题3:您能否通过repo、gist或Ember twiddle提供更完整的代码示例?()您是如何尝试筛选数据的?是的,它正在返回有效负载是的,我可以查看有效负载。我需要根据状态值筛选模型。
// route.js
model() {
  return this.store.findAll('note');
}

// controller.js
selectedStatus: 'SOME',
filteredModel: computed('model.length', 'selectedStatus', function() {
  return this.get('model').filterBy('status', this.get('selectedStatus'));
})