Ember js过滤模型中的数据

Ember js filtering the the data from the model

我正在尝试从 ember 模型中过滤数据,但找不到解决方案。

文件在app/routes/notes.js

import Route from '@ember/routing/route';

export default Route.extend({
  model()  {
    let l = this.store.findAll('note');
    return l;
  }
});

文件是app/templates/note.hbs

 {{#each model  as |note|}}
   Title: {{note.title}}<br/>
   Description: {{note.description}}<br/>
   Date:{{note.date}}<br/>
 {{/each}}

我正在尝试从模型中过滤数据 return,但它无法正常工作,因为我是 thought.The JSON 这里使用的格式是

{title: title, description: description, date:date, status: status}

我想根据状态过滤输出并显示在模板上。但我无法修改它显示一些错误的数据。我尝试过从模型本身或通过控制器操作进行过滤,但没有成功。谁能提出解决方案?

只过滤一次:

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'));
})