Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在ember.js中实现过滤_Javascript_Ember.js - Fatal编程技术网

Javascript 如何在ember.js中实现过滤

Javascript 如何在ember.js中实现过滤,javascript,ember.js,Javascript,Ember.js,我想使用谷歌地图在余烬创建应用程序。它看起来像谷歌地图,左边我想有过滤器,右边是地图。假设我的位置对象看起来像: { name: 'Luigi', type: 'pizza', ...} 在过滤器中,我想使用复选框选择我想在地图上显示的地方类型。默认情况下,所有元素都处于选中状态,每个选定类型的位置都显示在地图上 从这里开始我的问题。我看了peepcode,读了指南,但我不知道如何开始。 我想我需要一些FilterController来存储选定的过滤器数组,并且在Places中,control

我想使用谷歌地图在余烬创建应用程序。它看起来像谷歌地图,左边我想有过滤器,右边是地图。假设我的位置对象看起来像:

{ name: 'Luigi', type: 'pizza', ...}
在过滤器中,我想使用复选框选择我想在地图上显示的地方类型。默认情况下,所有元素都处于选中状态,每个选定类型的位置都显示在地图上

从这里开始我的问题。我看了peepcode,读了指南,但我不知道如何开始。 我想我需要一些
FilterController
来存储选定的过滤器数组,并且在
Places中,controllers
以某种方式
content
属性将从
FilterController
中查看类型数组,并基于此数组从模型返回
Places
集合

如何对上述情况下的场所实施过滤


现在,我正试图建立演示,列出了基于过滤器的地方,所有输入欢迎

您可以在阵列控制器上执行计算属性,根据接口指定的内容过滤阵列控制器:

App.PlacesController({
   content: [an array with your places],
   placesToDisplay: function(){
       return this.filter(function(item){
           return this.get('filter').contains(item.get('type')); //true when you want the item to be displayed.
       });
   }.property('content', 'filter'),
   filter: [] //containing the types you want to filter on.
});
请参阅视图中的
placesToDisplay
属性。并更新
过滤器
属性。由于
placesToDisplay
监视
filter
属性,因此当
filter
属性的内容更改时,它将重新呈现您的视图


到目前为止你都试了些什么?如果你愿意,我可以说得更具体一些。

对不起。补充质询。