jeudi 24 mars 2016

Ember simple array to display in component

Simple array in an component, that it will be display in a selector tag. I'm not being able to make it to work. The firstSelector doesn't display anything.

In the 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(),

In the 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>

if I write the firstSelector like this in the component.hbs, it will work:

 firstSelector: Ember.computed.sort('model.modelObjects', 'sortPropertiesAsc'),

How can I write it like the other way(as a function)




Aucun commentaire:

Enregistrer un commentaire