gpt4 book ai didi

ember.js - 过滤 Ember ArrayProxy

转载 作者:行者123 更新时间:2023-12-01 23:48:18 24 4
gpt4 key购买 nike

您将如何过滤 ArrayProxy 的结果?我已经尝试过 slice、filter、rejectBy,所有这些都导致 View 中没有结果。我想这是因为数据还不可用,但是 then(...) 的使用也没有成功。有什么想法吗?

shownEvents: function(){
return Em.ArrayProxy.createWithMixins(Em.SortableMixin, {
content: this.get('shownUser.events'),
sortProperties: ['eventTime.startTime', 'eventTime.endTime'],
sortAscending: true
});
}.property("shownUser"),

我已经查看了很多与此类似的文章,但没有找到任何有效的文章。

Can I add an additional computed property to an Ember ArrayProxy?

最佳答案

您可以过滤 ArrayProxy通过将函数传递给 filter并返回 true对于应该通过过滤测试的值。

类似于:

App.IndexRoute = Ember.Route.extend({
model: function() {
return { pets: [ { type: 'dog'}, { type: 'cat'}, { type: 'fish'}] };
}
});

App.IndexController = Ember.ObjectController.extend({
myPets: function(){
return Em.ArrayProxy.createWithMixins(Em.SortableMixin, {
content: this.get('pets'),
sortProperties: ['type'],
sortAscending: true
}).filter(function(item){ return item.type.length === 3});
}.property("pets"),
});

作品here

如果您已经尝试过,请随意忽略它 ;)

关于ember.js - 过滤 Ember ArrayProxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28021266/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com