Skip to content

SiTypeaheadDirective documentation

selectorexported-as
[siTypeahead]si-typeahead

Input Properties

NameTypeDefaultDescription
siTypeahead
Required
TypeaheadSet the options of the typeahead. Has to be either an Array or an Observable of an Array of options (string or object)
typeaheadAutocompleteListLabel
TranslatableString$localize`:@@SI_TYPEAHEAD.AUTOCOMPLETE_LIST_LABEL:Suggestions`Screen reader only label for the autocomplete list.
typeaheadAutoSelectIndex
number0Defines the index of the item which should automatically be selected.
typeaheadClearValueOnSelect
booleanfalseDefines whether the host value should be cleared when a value is selected.
typeaheadCloseOnEsc
booleantrueDefines whether the typeahead can be closed using escape.
typeaheadFullWidth
booleanfalseIf set, the typeahead will at minium have the width of the connected input field.
typeaheadItemTemplate
TemplateRef<TypeaheadOptionItemContext>Defines an optional template to use as the typeahead match item instead of the one built in. Gets the TypeaheadOptionItemContext passed to it.
typeaheadMatchAllTokens
("no" | "once" | "separately" | "independently")'separately'Defines whether and how to require to match with all the tokens if typeaheadTokenize is enabled. - no does not require all of the tokens to match. - once requires all of the parts to be found in the search. - separately requires all of the parts to be found in the search where there is not an overlapping different result. - independently requires all of the parts to be found in the search where there is not an overlapping or adjacent different result. ('independently' also slightly changes sorting behavior in the same way.)
typeaheadMinLength
number1Defines the number of characters the value of the host needs to be before a typeahead is displayed. Use 0 to have it display when focussing the host (clicking or tabbing into it).
typeaheadMultiSelect
booleanfalseDefines whether multiselection of typeahead is possible with checkboxes.
typeaheadOptionField
string'name'Defines the name of the field/property the option string is in when the typeahead options are objects.
typeaheadOptionsInScrollableView
number10If typeaheadScrollable is true , defines the number of items visible at once.
typeaheadOptionsLimit
number20Defines the maximum number of items added into the DOM. Default is 20 and 0 means unlimited.
typeaheadProcess
booleantrueTurns on/off the processing (searching and sorting) of the typeahead options. Is used when searching and sorting is done externally.
typeaheadScrollable
booleanfalseMakes the typeahead scrollable and sets its height. Uses typeaheadOptionsInScrollableView and typeaheadScrollableAdditionalHeight .
typeaheadScrollableAdditionalHeight
number13If typeaheadScrollable is true , defines the number of additional pixels to be added the the bottom of the typeahead to show users that it is scrollable.
typeaheadSkipSortingMatches
booleanfalseSkip the sorting of matches. If the value is true , the matches are sorted according to SiTypeaheadSorting .
typeaheadTokenize
booleantrueDefines whether to tokenize the search or match the whole search.
typeaheadWaitMs
number0Defines the number of milliseconds to wait before displaying a typeahead after the host was focused or a value inputted.

Output Properties

NameTypeDescription
typeaheadOnFullMatch
TypeaheadMatchEmits an Event when a typeahead full match exists. A full match occurs when the entered text is equal to one of the typeahead options. The event is a TypeaheadMatch
typeaheadOnInput
stringEmits an Event when the input field is changed.
typeaheadOnSelect
TypeaheadMatchEmits an Event when a typeahead match is selected. The event is a TypeaheadMatch
typeaheadOpenChange
booleanEmits whenever the typeahead overlay is opened or closed.
typeaheadClosed
Deprecated
voidDeprecated: Use typeaheadOpenChange instead.
typeaheadOnMultiselectClose
Deprecated
voidDeprecated: Never emits. Use typeaheadOpenChange instead.

Attributes and Methods

NameTypeDefaultDescription
(readonly) typeaheadOpen
booleanIndicates whether the typeahead is shown.

Types Documentation

Either a TypeaheadObservable (observable of a TypeaheadArray ) or a TypeaheadArray .
Represents a translatable string. This can either be a translation key, e.g. ACTIONS.EDIT that will be automatically translated when displayed on the UI or a pre-translated string, e.g. Edit . Equivalent to a normal string in usage and functionality.
An interface to define the context of a typeahead item template
Properties
index: number
item: TypeaheadOption
match: TypeaheadMatch
query: string
A typeahead match, which is a processed typeahead option.
Properties
atBeginning: boolean
iconClass?: string
itemSelected?: boolean
matches: number
matchesAllParts: boolean
matchesAllPartsSeparately: boolean
matchesEntireQuery: boolean
option: TypeaheadOption
result: MatchSegment[]
stringMatch: boolean
text: string
uniqueMatches: number
uniqueSeparateMatches: number
An array of TypeaheadOption .
An observable of a TypeaheadArray (array of TypeaheadOption ).
Translatable
import
A singular item to be used in the typeahead. Can be either a string or an object.
A segment of a TypeaheadMatch , which is a matching or non-matching segment of a typeahead option.
Properties
isMatching: boolean
matches: number
text: string
uniqueMatches: number
Constructor
() => {}
Properties
listbox?: SiAutocompleteListboxDirective<T>
Accessors
get active: (undefined | null | SiAutocompleteOptionDirective<T>)
get activeDescendant: string
get ariaControls: (undefined | string)
get expanded: boolean
Methods
Parameters
event: KeyboardEvent
Constructor
() => {}
Properties
autocomplete: InputSignal<SiAutocompleteDirective<T>> = ...
changeDetectorRef: ChangeDetectorRef = ...
destroyRef: DestroyRef = ...
id: InputSignal<string> = __si-autocomplete-listbox-${SiAutocompleteListboxDirective.idCounter++}
injector: Injector = ...
keyManager: ActiveDescendantKeyManager<SiAutocompleteOptionDirective<any>> = ...
options: Signal<readonly SiAutocompleteOptionDirective<any>[]> = ...
siAutocompleteDefaultIndex: InputSignal<number> = 0
siAutocompleteOptionSubmitted: OutputEmitterRef<(undefined | T)> = ...
idCounter: number = 0
Accessors
get active: (null | SiAutocompleteOptionDirective<T>)
Methods
A callback method that is invoked immediately after the default change detector has checked the directive's data-bound properties for the first time, and before any of the view or content children have been checked. It is invoked only once when the directive is instantiated.
ngOnInit: () => void from OnInit.ngOnInit
Parameters
event: KeyboardEvent
setActiveItem: () => void
Constructor
() => {}
Properties
active?: boolean
disabledInput: InputSignalWithTransform<boolean, unknown> = false
element: ElementRef<HTMLElement> = ...
id: InputSignal<string> = __si-autocomplete-option-${SiAutocompleteOptionDirective.idCounter++}
parent: SiAutocompleteListboxDirective<unknown> = ...
value: InputSignal<(undefined | T)> = undefined
idCounter: number = 0
Accessors
Whether the option is disabled.
get disabled: boolean from Highlightable.disabled
Methods
click: () => void
setActiveStyles: () => void from Highlightable.setActiveStyles
setInactiveStyles: () => void from Highlightable.setInactiveStyles

Except where otherwise noted, content on this site is licensed under MIT License.