Skip to content

SiTypeaheadDirective documentation

import { SiTypeaheadDirective } from '@siemens/element-ng/typeahead';

Input Properties

NameTypeDefaultDescription
siTypeaheadrequired
Typeahead

Set 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
number 0

Defines the index of the item which should automatically be selected.

typeaheadClearValueOnSelect
boolean false

Defines whether the host value should be cleared when a value is selected.

typeaheadCloseOnEsc
boolean true

Defines whether the typeahead can be closed using escape.

typeaheadCreateOption
TranslatableString | undefined

This option will be shown at the end of the typeahead. Use it to allow users to create new options on the fly.

Use the {{ query }} parameter in translation values to include the current text from the input.

typeaheadFullWidth
boolean false

If set, the typeahead will at minium have the width of the connected input field.

typeaheadItemTemplate
TemplateRef<TypeaheadOptionItemContext> | undefined

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
number 1

Defines 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
boolean false

Defines 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
number 10

If typeaheadScrollable is true, defines the number of items visible at once.

typeaheadOptionsLimit
number 20

Defines the maximum number of items added into the DOM. Default is 20 and 0 means unlimited.

typeaheadProcess
boolean true

Turns on/off the processing (searching and sorting) of the typeahead options. Is used when searching and sorting is done externally.

typeaheadScrollable
boolean false

Makes the typeahead scrollable and sets its height. Uses typeaheadOptionsInScrollableView and typeaheadScrollableAdditionalHeight.

typeaheadScrollableAdditionalHeight
number 13

If 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.

typeaheadScrollStrategy
ScrollStrategy defaultConnectedOverlayScrollStrategy()

CDK scroll strategy used for the typeahead overlay.

typeaheadSkipSortingMatches
boolean false

Skip the sorting of matches. If the value is true, the matches are sorted according to SiTypeaheadSorting.

typeaheadTokenize
boolean true

Defines whether to tokenize the search or match the whole search.

typeaheadWaitMs
number 0

Defines the number of milliseconds to wait before displaying a typeahead after the host was focused or a value inputted.

Output Properties

NameTypeDescription
typeaheadOnCreateOption
string

Emits when the create option is selected. It will emit the current search query.

typeaheadOnFullMatch
TypeaheadMatch

Emits 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
string

Emits an Event when the input field is changed.

typeaheadOnSelect
TypeaheadMatch

Emits an Event when a typeahead match is selected. The event is a TypeaheadMatch

typeaheadOpenChange
boolean

Emits whenever the typeahead overlay is opened or closed.

Attributes and Methods

NameTypeDescription
(readonly) typeaheadOpen
boolean

Indicates whether the typeahead is shown.

Types Documentation

import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';

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.

import type { Typeahead } from '@siemens/element-ng/typeahead';

Either a TypeaheadObservable (observable of a TypeaheadArray) or a TypeaheadArray.

import type { TypeaheadOptionItemContext } from '@siemens/element-ng/typeahead';

An interface to define the context of a typeahead item template

import type { TypeaheadArray } from '@siemens/element-ng/typeahead';

An array of TypeaheadOption.

import type { TypeaheadObservable } from '@siemens/element-ng/typeahead';

An observable of a TypeaheadArray (array of TypeaheadOption).

import type { TypeaheadOptionSource } from '@siemens/element-ng/typeahead';

Defines a source of options for the SiTypeaheadDirective. Use it for server-side pre-filtering.

This function will be called, whenever the search value is updated by the user.

A loading indicator is shown when this function was called until the Observable completes.

import type { TypeaheadOption } from '@siemens/element-ng/typeahead';

A singular item to be used in the typeahead. Can be either a string or an object.

import type { MatchSegment } from '@siemens/element-ng/typeahead';

A segment of a TypeaheadMatch, which is a matching or non-matching segment of a typeahead option.


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