0.1.1 • Published 5 years ago

by-typeahead v0.1.1

Weekly downloads
8
License
-
Repository
-
Last release
5 years ago

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

AttributeType
datathe data the typeahead is going to search trough
inputDescriptionthe description that is displayed right next to the first result
searchAfterInputFunctionyou 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
typeaheadSearchFunctionhere you can pass your own logic to search trough your data, just return the results as an array