Ember Powerselect数据格式

时间:2017-10-24 00:20:41

标签: ember.js

我正在查看其所需格式的文档。但我想知道如何添加选项的ID。

groupedNumbers: [
    { groupName: 'Smalls', options: ['one', 'two', 'three'] },
    { groupName: 'Mediums', options: ['four', 'five', 'six'] },
    { groupName: 'Bigs', options: [
        { groupName: 'Fairly big', options: ['seven', 'eight', 'nine'] },
        { groupName: 'Really big', options: [ 'ten', 'eleven', 'twelve' ] },
        'thirteen'
      ]
    },
    'one hundred',
    'one thousand'
  ]

以下是我要做的事情

groupedNumbers: [
    { groupName: 'Smalls', options: [{
        id: 1,
        name: 'one'
    },
    {
        id: 2,
        name: 'two'
    }]
  ]

这是我调用组件的地方

<label for="menu-group-list">Service Category</label>
{{#power-select
  options=groupedCategories
  searchEnabled=true
  selected=selectedSubCategoryName
  selectedItemComponent="selected-service"
  onchange=(action "serviceSubCategoryChanged")
  as |category| }}
    {{category}}
{{/power-select}}

我以为我可以覆盖optionsComponent,但这不起作用。想法?

1 个答案:

答案 0 :(得分:0)

  1. options=groupedCategories您需要提供options=groupedNumbers
  2. 而不是{{category}},您需要说{{category.name}}