SelectionController

A SelectionController tracks one or more selected values.

OptionTypeDefaultValueDescription
selectedstring or string[]null or []The controller's initial selected value.
validationfunction(any) => booleanOptional - A function that accepts a value from the select method and returns whether or not to add this value to selected.
togglebooleanfalseOptional - When true, selecting an already-selected item will deselect it instead.
multiplebooleanfalseOptional - When true, the controller will track multiple selected values.
PropertyTypeDescription
multiplebooleanWhether the controller will support multiple selections at once.
togglebooleanWhether the controller will toggle selections.
hasSelectedbooleanWhether the controller has a selected value
validation(any) => booleanA method for validating values passed to select method.
MethodDescription
select(item: any)Select an item. If the controller has a validation method, the item will only be selected if this method returns true. If multiple is selected, the value will be added to the selected array; if not, the new value will replace the old one. If toggle is enabled, selecting an already-selected item will deselect it instead.
deselect(item: any)Deselect an item.
isSelected(item: any)Whether the given item is selected.
clear()Remove any selected item(s).

Example: