如何将对象数组传递给聚合物组件

How to pass array of objects to polymer component

我是 Meteor 的新手,正在尝试 Meteor + Polymer,有一个问题。它看起来很简单但它不起作用:-(

我想将对象数组传递给创建的聚合物组件(见下文)

在 Meteor 模板“userShowDashboard”中:

这个组件有效

<belo-test 
    items='[{"title": "Title 1"}, {"title": "Title 2"}]'
    header='Test HEADER'>
</belo-test>  

但是,这个不是(没有显示任何项目)

<belo-test 
    items={{getItems}}
    header='Test HEADER'>
</belo-test>  

这是流星辅助函数

Template.userShowDashboard.helpers
  getItems: ->
    [{"title": "Title 1"}, {"title": "Title 2"}]

聚合物成分

<polymer-element name="belo-test" attributes="items header">
  <template>
          <core-submenu label="{{header}}" icon="apps" active>
            <template repeat="{{item in items}}">  
                <a href="#">
                  <paper-item data-action="switch-project">
                    <core-icon icon="chevron-right"></core-icon>
                      {{item.title}}
                  </paper-item>
                </a>                
              </template>  
          </core-submenu> 
  </template>
  <script>
  Polymer('belo-test',{
    items: []
  });
  </script>
</polymer-element>

感谢您的任何建议。

请试试这个并告诉我:

Template.userShowDashboard.helpers
  items: ->
    JSON.stringify([{"title": "Title 1"}, {"title": "Title 2"}])
  header: ->
    "This is the Header"

...使用此模板代码:

<belo-test 
    items="{{items}}"
    header="{{header}}">
</belo-test>