【发布时间】:2016-07-12 02:07:23
【问题描述】:
组件中的简单数组,它将显示在选择器标签中。我无法让它工作。 firstSelector 不显示任何内容。
在component.js中:
sortPropertiesAsc: ['value:asc'],
selectors: ['model.modelObjects', 'model.location'],
firstSelector: function(){
const firstGroupObjects = this.get('selectors')[0];
return Ember.computed.sort(firstGroupObjects, 'sortPropertiesAsc');
}.property(),
在component.hbs中
<select onchange={{ action 'selectBrand' value="target.value" }}>
<option value="" >Select company</option>
{{#each firstSelector as |company|}}
<option value={{company.id}} selected={{eq brand company.id}}> {{company.value}}</option>
{{/each}}
</select>
如果我在component.hbs中这样写firstSelector,它将起作用:
firstSelector: Ember.computed.sort('model.modelObjects', 'sortPropertiesAsc'),
我怎样才能像其他方式(作为函数)那样编写它
【问题讨论】:
标签: javascript ember.js components selector