ember.jsember.js-2

How do I access properties from within an Ember 2 component?


I am having some trouble accessing properties passed to my Ember component, which is as follows:

import Ember from 'ember';

export default Ember.Component.extend({
    isRowEditorActive: function() {
        return this.get('items').length > 0;
    }.property('items'),

    actions: {
        // My actions here
    }
});

The items (list of strings) that I pass in, can be accessed without problems within the template {{line-items-table items=['asd', 'asd']}}

However trying to get them within the component just returns undefined. Any suggestions?


Solution

  • As @kristjan says, you'll need to define your items for the line-item-table in the parent.

    This is due to that the current version of handlebars don't support inline arrays, https://github.com/wycats/handlebars.js/issues/1058