简体   繁体   English

如何从Ember 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: 我在访问传递给我的Ember组件的属性时遇到一些麻烦,如下所示:

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']}} 我传入的items (字符串列表)可以在模板{{line-items-table items=['asd', 'asd']}}访问而不会出现问题

However trying to get them within the component just returns undefined. 但是试图get他们中的分量刚刚返回undefined。 Any suggestions? 有什么建议么?

As @kristjan says, you'll need to define your items for the line-item-table in the parent. 正如@kristjan所说,您需要为父 items中的line-item-table定义items

This is due to that the current version of handlebars don't support inline arrays, https://github.com/wycats/handlebars.js/issues/1058 这是因为当前版本的把手不支持内联数组https://github.com/wycats/handlebars.js/issues/1058

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM