我正在尝试根据相关模型过滤集合,我已经尝试了几种方法,但无法使其正常工作:
App.BetroundStatsController = Ember.ArrayController.extend({
needs: "betround",
queryParams: ['query_game'],
sortProperties: ['user.nickName'],
query_game: null,
computeFilter: Ember.computed.filterBy('model','game', this.get('query_game')),
filtered: function(){
return this.get('model').filterProperty('game', this.get('query_game'));
}.property('model.@each.game','query_game'),
filteredBets: function() {
var game = this.get('query_game');
var bets = this.get('model');
if (game) {
return bets.filter(function(item){
return(item.get('game.id') == game);
} );
} else {
return bets;
}
}.property('query_game', 'model'),
newestFilter: function(){
var cont = this;
return this.get('model').filter(function(item, index, self) {
if (item.get('game.id') == cont.get('query_game') ) {
return true;
}
})
}.property('model.@each.game'),
});