Overview
TheAutoComplete class provides an autocomplete input field with filtering capabilities. It supports both single and multiple selection modes and dynamically filters options as the user types.
Inheritance
Constructor
Parameters
The unique identifier for the autocomplete node in the DOM.
The placeholder text to display when no value is selected.
The options to display in the autocomplete. Can be an array, Promise, or Observable of OptionChild objects.
The initial selected value(s) of the autocomplete.
Whether to allow multiple selections.
Whether to display the node in a single line layout.
Material icon name to display in the autocomplete field.
Custom error message to display when validation fails.
Whether the autocomplete is disabled.
Synchronous validator function(s) or control options.
Asynchronous validator function(s) for the autocomplete.
Action(s) to execute when events occur on the autocomplete.
Properties
| Property | Type | Description |
|---|---|---|
id | string | The unique identifier for the node |
placeholder | string | The placeholder text |
type | 'autocomplete' | The node type (read-only) |
value | OptionChild[] | The options available for selection |
selectedValue | string | The currently selected value(s) |
multiple | boolean | Whether multiple selections are allowed |
filteredOptions | BehaviorSubject<OptionChild[]> | Observable of filtered options based on user input |
singleLine | boolean | Whether displayed in single line layout |
icon | string | Material icon name |
errorMessage | string | Custom error message |
disabled | boolean | Whether the node is disabled |
validator | Validator | AbstractControlOptions | Synchronous validators |
asyncValidator | AsyncValidatorFn | Asynchronous validators |
action | Action | Action[] | Associated actions |
hint | string | Hint text to display |
autoFocus | boolean | Whether to auto-focus on load |
Methods
getOptions()
Returns the current list of options.getNativeElement()
Returns the native DOM element for this node.Usage Example
Special Features
Filtered Options
ThefilteredOptions property is a BehaviorSubject that automatically updates as the user types, providing real-time filtering of available options. Subscribe to this observable to react to filtered option changes:
Async Data Loading
The autocomplete supports loading options asynchronously via Promises or Observables, making it ideal for fetching data from APIs:Related Node Types
- Dropdown - Similar selection interface without filtering
- RadioGroup - For mutually exclusive selections with visible options
- SelectableNode - Base class for all selection nodes
