Greentube / ngx-typeahead

Typeahead multi-select dropdown component for angular. Demo:
https://greentube.github.io/ngx-typeahead/demo
MIT License
22 stars 11 forks source link
angular typeahead typeahead-component typescript

ngx-typeahead

npm version Build Status Build Status

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:

Usage

In order to use ngx-type-ahead you need to import the module and simply place component in your template.

@NgModule({
  imports: [
    TypeaheadModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
<type-ahead formControlName="myControl" [suggestions]="mySuggestions"></type-ahead>

API

DOM element properties

Type-ahead supports following properties:

TypeaheadSuggestions

Type representing suggestions. Can be:

TypeaheadSettings

export interface TypeaheadSettings {
  /** how much should be user's typing debounced */
  typeDelay: number; // Default is `50`
  /** maximal number of visible items in dropdown. If value is 0, list will not be limited */
  suggestionsLimit: number; // Default is `10`
  /** text shown when there are no matches */
  noMatchesText: string; // Default is `No matches found`

  /** css classes for parts of type-ahead */
  tagClass: string; // Default is `btn badge badge-primary`
  tagRemoveIconClass: string; // Default is ``
  dropdownMenuClass: string; // Default is `dropdown-menu`
  dropdownMenuExpandedClass: string; // Default is `dropdown-menu show`
  dropdownMenuItemClass: string; // Default is `dropdown-item`
  dropdownToggleClass: string; // Default is `dropdown-toggle`
}

License

Licensed under MIT