J'ai deux types de valeurs de tri. sur le clic je devrais mettre à jour mon ordre de tri et exiger de mettre à jour le HTML. Mais pour l'instant, je ne reçois aucune mise à jour.Comment mettre à jour le "tri" par une valeur différente?
Live Demo for update in Twiddle
un scénario est numéro et l'autre est par date ("07/07/2017").
voici mon essai: // pas du tout fonctionne !!
sortByDateOfPurchase: Ember.computed(function(){
return privateArray.sort(function(a,b){
console.log(b['date_of_purchase']);
return parseInt(b['date_of_purchase']) - parseInt(a['date_of_purchase']);//07/07/2017
})
}),
//works but not constant
sortByAmountSpent:Ember.computed(function(){
return privateArray.sort(function(a,b){
return parseInt(b['amount-spent']) - parseInt(a['amount-spent']);
})
}),
sortTheCards(title){
//changing the sorted array but not working
if(title=='amountSpent'){
//setting for date value
this.set('sortedCards', this.get('sortByAmountSpent'));
return;
}
//setting for number value
this.set('sortedCards', this.get('sortByDateOfPurchase'));
},
selectedDetails : [],
transactionService: Ember.inject.service(),
filterValue:Ember.observer('filterBy', function(){
var sortBy = this.get('filterBy');
this.sortTheCards(sortBy);
}),
init() {
this._super(...arguments);
this.set('selectedDetails', this.get('transactionService.selectedTransactions'));
var sortBy = this.get('filterBy');
var nestedCards = this.get('nestedCards');
this.sortTheCards(sortBy);
},