Skip to content

Grouping

Use the groupBy input to group options by an item key or a function expression.

Selectable groups with hidden selected items

Section titled “Selectable groups with hidden selected items”

Inputs used by the examples on this page:

Input Type Default Description
[groupBy] string | Function null Allow to group items by key or function expression
[groupValue] (groupKey: string, children: any[]) => Object - Function expression to provide group value
[selectableGroup] boolean false Allow to select group when groupBy is used
[selectableGroupAsModel] boolean true Indicates whether to select all children or group itself
[hideSelected] boolean false Allows to hide selected items.
[items] Array<any> [] Items array
[multiple] boolean false Allows to select multiple items.
[closeOnSelect] boolean true Whether to close the menu when a value is selected
[compareWith] (a: any, b: any) => boolean (a, b) => a === b A function to compare the option values with the selected values. The first argument is a value from an option. The second is a value from the selection(model). A boolean should be returned.
bindLabel string label Object property to use for label. Default label
bindValue string - Object property to use for selected model. By default binds to whole object.

See the NgSelectComponent API reference for the complete list of inputs and outputs.