- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您将如何过滤 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/
这是我的代码 /***************************************************** *****/ import Ember from "ember"; var
如何扩展 Ember.ArrayProxy?我尝试过以下方法: Ember.ArrayProxy.reopenClass({ flatten: function(){ var r = []
目标 创建由 ArrayController (ArrayProxy) 管理的模型数组。 要求 使用ArrayController(ArrayProxy)抽象封装Model的数组 插入 ArrayPr
在 Ember MVC TodoApp 上有一个选项“清除所有已完成”。 我一直在尝试做一个简单的“全部清除”。 我尝试了多种方法,但都没有按预期工作(清除数据、本地存储和刷新 UI)。 示例附带的代
您将如何过滤 ArrayProxy 的结果?我已经尝试过 slice、filter、rejectBy,所有这些都导致 View 中没有结果。我想这是因为数据还不可用,但是 then(...) 的使用也
如果我在模型中使用 ArrayProxy,则找不到更新该数组中特定元素属性的方法。 这是我的示例路由和 Controller : App.IndexRoute = Ember.Route.extend
我有一个类别列表。每个类别都可以有子类别。这是我创建的模型: App.Category = Em.Object.extend({ id: null, name: null, s
有人可以看一下这个吗:http://jsfiddle.net/tur9b/9/ 这是一个简单的有序列表。您可以通过单击名称来删除列表条目。 IE(在 IE9 中测试)显示出奇怪的行为。目前我完全不知道
我有一个数组,我想要对其项目进行分组,然后以这种分组方式显示。这一切都非常令人困惑: App.GroupedThings = Ember.ArrayProxy.extend({ init: fun
我怀疑有一种方法可以更新 Ember.Array 代理来触发 ember 的通知,但我不知道如何实现。 我正在覆盖“content”属性来更新数组。数组会更新,但 View 不会更新。 App.ite
通常,我需要遍历 Ember.ArrayProxy 对象的内容。 例1 ,我需要建立一个 ID 列表: var loc = myArrayProxy.get('length') || 0, i
我是一名优秀的程序员,十分优秀!