ngx-typeahead
Typeahead multi-select dropdown component for angular. Demo
The version 2.x.x is for Angular 6+. If you are using older version of Angular (v2-v5) please use previous version.
Table of contents:
Installation
npm install --save ngx-type-ahead
How it works
Type ahead uses (observable) array of items to suggest value to user based on current value of the input.
Items can be simple strings or they could be objects. Here is a brief list of functionality:
- Standard type ahead functionality
- Custom inputs (only if suggestions are strings)
- Fixed scope of values - limited to suggestions
- Selecting multiple values
- Suggestions as an array or observable of array
- Suggestion as an object - user specifies which property is
view value
and which isvalue indentifier
.
Usage
In order to use ngx-type-ahead
you need to import the module and simply place component in your template.
API
DOM element properties
Type-ahead
supports following properties:
suggestions: TypeaheadSuggestions
- List or observable list of elements which represent set of possible suggestions. For more information on type check TypeaheadSuggestions.
Default value is[]
.itemTemplate: TemplateRef
- Custom template template for items in suggestions list and badges in multi select scenario. Exposed properties areitem
andindex
.custom: boolean
- Flag indicating whether custom values are allowed.
Default value istrue
.multi: boolean
- Flag indicating whether control accepts multiple values/array of values.
Default value isfalse
.complex: boolean
- Flag indicating whether suggestion represents an Object instead of simple string.
Default value isfalse
.idField: string
- Only forcomplex
suggestions. Object's indicator property name used as a value for form component. Can be just in combination withmulti
, but automatically cancelscustom
.
Default value isid
.nameField: string
- Only forcomplex
suggestions. Object's name property. This value will be shown in dropdown and in the input, butidField
will be saved to form.
Default value isname
.settings: TypeaheadSettings
- Additional typeahead settings, mostly style related that will most likely be shared among differenttype-ahead
elements.
TypeaheadSuggestions
Type representing suggestions. Can be:
- string[]
- Object[]
- Observable<string[]>
- Observable<Object[]>
TypeaheadSettings
License
Licensed under MIT