README
by-typeahead
A typeahead built for Angular
Usage
Import the package in your app.module.ts
- Important note: if you haven't imported the FormsModule, add it to your imports
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ByTypeaheadModule } from 'by-typeahead';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [FormsModule, ByTypeaheadModule],
providers: [],
bootstrap: [AppComponent]
})
Now just use the selector whereever you need the typeahead:
you have to/ can provide your own set of data in the form of an array.
you should provide a description, so the user knows whats going on with the first result of the typeahead
<by-typeahead [data]="yourData" [inputDescription]="Your - Searchkey"></by-typeahead>
Attributes
Attribute | Type |
---|---|
data | the data the typeahead is going to search trough |
inputDescription | the description that is displayed right next to the first result |
searchAfterInputFunction | you can write your own function, what should happen with the input (is stored in variable this.userInput ) after the user pressed enter e.g pass the input to elasticsearch |
typeaheadSearchFunction | here you can pass your own logic to search trough your data, just return the results as an array |