# ng2-autocomplete-component

> An angular 2 library that provides autocomplete UI element functionality

Latest version **0.0.6** (published 2016-10-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng2-autocomplete-component
pnpm add ng2-autocomplete-component
yarn add ng2-autocomplete-component
bun add ng2-autocomplete-component
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2016-10-29 |
| First published | 2016-10-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+22 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yuval Birenboum |
| Maintainers | yuvalbi |
| Keywords | Angular, 2, autocomplete, component, UI |

## Links

- npm: https://www.npmjs.com/package/ng2-autocomplete-component
- Repository: https://github.com/tWinE-xx/ng2-autocomplete
- Homepage: https://github.com/tWinE-xx/ng2-autocomplete#readme
- Issues: https://github.com/tWinE-xx/ng2-autocomplete/issues
- npm.io page: https://npm.io/package/ng2-autocomplete-component

## Dependencies (6)

- [rxjs](https://npm.io/package/rxjs.md) ^5.0.0-rc.1
- [@angular/core](https://npm.io/package/@angular/core.md) ^2.1.1
- [@angular/http](https://npm.io/package/@angular/http.md) ^2.1.1
- [@angular/forms](https://npm.io/package/@angular/forms.md) ^2.1.1
- [@angular/common](https://npm.io/package/@angular/common.md) ^2.1.1
- [@angular/compiler](https://npm.io/package/@angular/compiler.md) ^2.1.1

## Alternatives

- [@progress/kendo-ooxml](https://npm.io/package/@progress/kendo-ooxml.md) — 152.1K weekly downloads
- [@progress/kendo-react-ripple](https://npm.io/package/@progress/kendo-react-ripple.md) — 8.0K weekly downloads
- [@progress/kendo-react-orgchart](https://npm.io/package/@progress/kendo-react-orgchart.md) — 4.3K weekly downloads
- [@praxisui/dynamic-fields](https://npm.io/package/@praxisui/dynamic-fields.md) — 2.4K weekly downloads
- [@progress/kendo-vue-listbox](https://npm.io/package/@progress/kendo-vue-listbox.md) — 932 weekly downloads

## Recent versions

- 0.0.6 (latest) — 2016-10-29
- 0.0.5 — 2016-10-28
- 0.0.4 — 2016-10-28
- 0.0.3 — 2016-10-28
- 0.0.2 — 2016-10-28

## README

# ng2-autocomplete-component

# Installation
```js
npm install ng2-autocomplete-component
```

## Install & run the sample application (usage demo) 
    
    cd examples/systemjs
    npm install
    npm start
    
Then access [http://localhost:3000](http://localhost:3000)

## Usage

### import AutoComplete components and AutoCompleteConfig class

```js
import {AutoComplete, AutoCompleteConfig} from 'ng2-autocomplete-component/components';
```

### initalize AutoCompleteConfig class

for autocomplete data from rest api (GET) 

```js
let apiUrl = 'http://localhost:3000/data/api-response.json';
let minCharsForSearch = 1;
let placeholder = 'search..';//min amount of chars before autocomplete mayches results
let responseApiKey = 'id';//a reference to the key for example api response [{"id":1,"name":"USA"}, {..}]
let responseApiText = 'name';//a reference to the text for example api response [{"id":1,"name":"USA"}, {..}]
//init config class
this.autocompleteConfigAPISource = new AutoCompleteConfig(apiUrl, minCharsForSearch, placeholder, responseApiKey, responseApiText); 
```

for autocomplete data from Array

```js
let dataArray = [{"id":1,"name":"USA"}, {"id":1,"name":"UK"}, {"id":1,"name":"Italy"}];
let minCharsForSearch = 1;
let placeholder = 'search..';//min amount of chars before autocomplete mayches results
let responseApiKey = 'id';//a reference to the key for example api response [{"id":1,"name":"USA"}, {..}]
let responseApiText = 'name';//a reference to the text for example api response [{"id":1,"name":"USA"}, {..}]
//init config class
this.autocompleteConfigAPISource = new AutoCompleteConfig(dataArray, minCharsForSearch, placeholder, responseApiKey, responseApiText); 
```

### put component in template
```js
template: `
        <hr>
        <h1>ng2-autocomplete - data source form rest API (GET)</h1>
        <!-- *** you must put #id on component to get the result back --> 
        <autocomplete #myAutoCompleteId [config]="autocompleteConfigAPISource"></autocomplete>
        <h4>* you need to leave field to see which term selected</h4>
        <!-- use selected value using component id -->
        <h2>RESULT SELECTED: </h2>{{myAutoCompleteId.term.value}}
    `
```

---
_Source: https://npm.io/package/ng2-autocomplete-component · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
