Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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 余烬重新渲染组件中的自定义数组。选择器_Javascript_Jquery_Ember.js - Fatal编程技术网

Javascript 余烬重新渲染组件中的自定义数组。选择器

Javascript 余烬重新渲染组件中的自定义数组。选择器,javascript,jquery,ember.js,Javascript,Jquery,Ember.js,我有一个Ember应用程序,它有一个带有几个下拉菜单的模板(下拉菜单位于component.hbs中)。 在component.js中,有一个自定义数组(components),它从模型中获取对象,并根据选择对其进行过滤。 问题是以下选择器的数据不会自动刷新,我必须刷新网站才能看到下一个选项 例如:2个选择器:“配方”和“配料” 用户选择“肉糕”。配料选择器将从组件中的自定义数组中获取数据,它不会刷新自身以仅显示肉糕的配料。 我假设发生这种情况是因为当用户访问网站时,component.hbs(

我有一个Ember应用程序,它有一个带有几个下拉菜单的模板(下拉菜单位于component.hbs中)。 在component.js中,有一个自定义数组(components),它从模型中获取对象,并根据选择对其进行过滤。 问题是以下选择器的数据不会自动刷新,我必须刷新网站才能看到下一个选项

例如:2个选择器:“配方”和“配料” 用户选择“肉糕”。配料选择器将从组件中的自定义数组中获取数据,它不会刷新自身以仅显示肉糕的配料。
我假设发生这种情况是因为当用户访问网站时,component.hbs(和ingredientes数组)已被呈现和加载,但我需要找到一种方法,每当用户选择配方时刷新配料数组定义组件中的计算属性,只要
选择了删除
更改,就会重新计算

ingredients:Ember.computed('selectedRecipe', function(){
 // do filtering stuff and return the result
 return this.get('customArray').filterBy('name',this.get('selectedRecipe'));
})
所以,我就想出来了。 这比我想象的要简单得多。
在用户选择配方时触发的相同操作中,我清空数组中的成分,然后用与选择相关的成分填充它。

您能提供一个setupController代码的示例吗?类似于这样的内容?:setupController:function(controller,model){this.\u super(controller,model);Ember.set(model,'component',ingredientArray);Ember.set(model,'price',pricesArray);},是否应该在控制器中定义数组以使其工作?