lundi 2 novembre 2015

emberjs - Pass dynamic arguments to the component helper

How can I pass dynamic arguments to the component helper.

In production, I am iterating over a json hash that will render different components with different attrs each time.

I have a scaled down example in this jsbin.

I am returning this json hash:

  columns: Ember.computed('people.[]', function() {
    return this.get('people').map(function(person){
      return {
        component: 'x-person',
        attrs: {
          person: person
        }
      };
    });
  })

That I then iterate over and try and pass the arguments into the component:

{{#each columns as |column|}}
  {{component column.component column.attrs}}
{{/each}}

The component is getting created but the attributes are not set.

How can I properly pass the arguments to the component helper?




Aucun commentaire:

Enregistrer un commentaire