Quantcast
Viewing all articles
Browse latest Browse all 4827

How can I sort or filter my Model

@Rossi_Rasloff wrote:

I have a user Model and some action in the Controller, but I want to sort the result.

can some one help me out ???

Blockquote indent preformatted text by 4 spaces

export default Controller.extend({

appName: ‘Ember Twiddle User’,

filteredItems: computed(

'filterFirstName',
'filterLastName',
'filterCity',
'filterZipCode',
'filterFisatLevel',
'model.[]',
function() {
return this.model.filter((user) => {
  return (!this.filterFirstName || user.firstName.includes(this.filterFirstName))
    && (!this.filterLastName || user.lastName.includes(this.filterLastName))
    && (!this.filterCity || user.city.includes(this.filterCity))
    && (!this.filterZipCode || user.zipCode.includes(this.filterZipCode))
    && (!this.filterFisatLevel || user.fisatLevel >= this.filterFisatLevel)
    ;
});

}),

pagedItems: computed(‘filteredItems.’, function() {

return this.filteredItems.slice(0, 20);   // number of users

}),

});

indent preformatted text by 4 spaces

Blockquote

how to filter / sort by firstname or last name DESC / ASC ??

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4827

Trending Articles