Answer the question
In order to leave comments, you need to log in
Ember. How to filter data?
I am using CouchDB as a database.
//route
import Ember from 'ember';
export default Ember.Route.extend({
model: function () {
return this.store.findAll('task');
}
});
//model
import DS from "ember-data";
export default DS.Model.extend({
assigned: DS.attr('string'),
client: DS.attr('string'),
contact: DS.attr('string'),
date_finish: DS.attr('string'),
date_start: DS.attr('string'),
priority: DS.attr('string'),
state: DS.attr('string'),
text: DS.attr('string'),
title: DS.attr('string'),
});
Answer the question
In order to leave comments, you need to log in
Depends on how you use the data.
export default Ember.Route.extend({
model: function () {
return this.store.findAll('task').then(function(tasks){
return tasks.filterBy('state', 'done');
});
}
});
export default Ember.Component.extend({
filtredData: function() {
return this.get('data').filterBy(this.get('filterKey'), this.get('filterValue'));
}.property('data', 'filterKey', 'filterValue')
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question