Search code examples
angularjsui-select2

Passing already grouped options to angular ui-select


Is it possible somehow to pass already groped option to angular ui-select, like for jquery select2 Grouping results in Select2? For me not possible use group-by because some options don't have parent.

[     
      {id: 3, text: "Item name 3 without parent."},
      {text: "Group name", children: [
          {id: 1, text: "Item name 1"}, 
          {id: 2, text: "Item name 2"}
      ]}
    ]

Solution

  • You probably solved this already, but for future reference:

    When some of elements do not have a parent, select.ui will create a nameless group for them and show them at the beginning of list. So you can use group-by in this case.