0.1.1 • Published 8 years ago

ng2-yata v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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.