ng2-yata
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Yet Another Typeahead for Angular2

A simple typeahead implementation which provides autocompletion of input values separated by whitespace.

Build Status

demo

Install

npm install ng2-yata --save

Usage

import { Component } from '@angular/core';
import { Yata } from 'ng2-yata';
 
@Component({
  template: `<yata [placeholder]="placeholder"
                   [inputStyle]="inputStyle"
                   [inputStyleClass]="inputStyleClass"
                   [suggestions]="suggestions"
                   [(ngModel)]="filterValue"
                   (onComplete)="onInputComplete($event)></yata>`,
  directives: [ Yata ]
})
export class AppComponent {
  private placeholder: string = 'Enter Text';
  private suggestions: string[] = []; // available suggestions
  private filterValue: string = '';
  private inputStyle = ''; // input element inline css style
  private inputStyleClass = { // input element style classes to apply
    'form-control': true,
    'conditional-style-class': apply
  };
  private apply: boolean = false; // conditionally apply the css class
 
  onInputComplete(event: any) {
    // Input value accessible through event.value and this.filterValue
    // Find suggestions and populate suggestions array
  }
}

Additional Attributes

style Containing element inline style.

styleClass Containing element style classes.

delay The amount of milliseconds to wait, after typing has stopped, to execute the onComplete callback.

Package Sidebar

Install

npm i ng2-yata

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • jasondana