All Projects → gmerabishvili → angular-ng-autocomplete

gmerabishvili / angular-ng-autocomplete

Licence: MIT License
NPM package for Angular: https://www.npmjs.com/package/angular-ng-autocomplete

Programming Languages

typescript
32286 projects
HTML
75241 projects
SCSS
7915 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to angular-ng-autocomplete

autocomplete
Efficient and effective query auto-completion in C++.
Stars: ✭ 28 (-77.24%)
Mutual labels:  autocomplete
anaconda go
AnacondaGO adds autocompletion, linting and IDE features for Golang to your Sublime Text 3
Stars: ✭ 39 (-68.29%)
Mutual labels:  autocomplete
react-dadata-box
React component for use DaData service API (suggestions)
Stars: ✭ 25 (-79.67%)
Mutual labels:  autocomplete
vanilla-place-picker
Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android
Stars: ✭ 113 (-8.13%)
Mutual labels:  autocomplete
ng-sq-ui
Flexible and easily customizable UI-kit for Angular 11+
Stars: ✭ 99 (-19.51%)
Mutual labels:  autocomplete
Elasticsearch-Autocomplete-API-Sample
Building Autocomplete API with Completion Suggester in ASP.NET Core sample project
Stars: ✭ 20 (-83.74%)
Mutual labels:  autocomplete
nama
Namespaced Aliases: organize and easily find aliases using autocomplete & namespacing
Stars: ✭ 26 (-78.86%)
Mutual labels:  autocomplete
django-select2
This is a Django integration for Select2
Stars: ✭ 73 (-40.65%)
Mutual labels:  autocomplete
vue-single-select
single select dropdown with autocomplete
Stars: ✭ 43 (-65.04%)
Mutual labels:  autocomplete
idea-php-advanced-autocomplete
Plugin for PhpStorm IDE. Adds auto-completion support for various built-in PHP functions, where parameter is a string literal.
Stars: ✭ 57 (-53.66%)
Mutual labels:  autocomplete
Alter-Entity-Autocomplete
Drupal 8 module to alter Entity Autocomplete suggestion list.
Stars: ✭ 38 (-69.11%)
Mutual labels:  autocomplete
AutoAddProblem
qduoj自动化加题-该项目已经停止更新
Stars: ✭ 23 (-81.3%)
Mutual labels:  autocomplete
mongoose-graphql-pagination
GraphQL cursor pagination (Relay-like) for Mongoose models.
Stars: ✭ 29 (-76.42%)
Mutual labels:  autocomplete
vue-thailand-address
🇹🇭 Thai address input for Vue.
Stars: ✭ 44 (-64.23%)
Mutual labels:  autocomplete
pheniqs
Fast and accurate sequence demultiplexing
Stars: ✭ 14 (-88.62%)
Mutual labels:  autocomplete
config
Fig's integrations with bash, zsh, fish, ssh, and tmux. Also contains Fig's installation and update scripts. Finally, this repo is the root of the .fig folder that is installed on your computer when you download Fig!
Stars: ✭ 44 (-64.23%)
Mutual labels:  autocomplete
svelecte
Selectize-like component written in Svelte, also usable as custom-element 💪⚡
Stars: ✭ 121 (-1.63%)
Mutual labels:  autocomplete
AndroidIDE
AndroidIDE is an IDE for Android to develop full featured Android apps on Android smartphones.
Stars: ✭ 98 (-20.33%)
Mutual labels:  autocomplete
macOS-global-autocomplete
📃 System-wide autocompleting that learns what you type and works in any app! (also slightly scary maybe don't use this...)
Stars: ✭ 26 (-78.86%)
Mutual labels:  autocomplete
autocompletex
redis autocomplete for elixir
Stars: ✭ 22 (-82.11%)
Mutual labels:  autocomplete

Angular Autocomplete

Table of contents

Features

  • Flexible autocomplete with client/server filtering.
  • Variable properties and event bindings.
  • Selection history.
  • Custom item and 'not found' templates.
  • Infinite scroll.
  • Compatible with Angular forms API (Both Reactive and Template-driven forms).
  • Keyboard navigation.
  • Accessibility.

Getting started

Step 1: Install angular-ng-autocomplete:

NPM

npm i angular-ng-autocomplete

Step 2: Import the AutocompleteLibModule:

import {AutocompleteLibModule} from 'angular-ng-autocomplete';

@NgModule({
  declarations: [AppComponent],
  imports: [AutocompleteLibModule],
  bootstrap: [AppComponent]
})
export class AppModule {}

Usage sample

<div class="ng-autocomplete">
<ng-autocomplete 
  [data]="data"
  [searchKeyword]="keyword"
  (selected)='selectEvent($event)'
  (inputChanged)='onChangeSearch($event)'
  (inputFocused)='onFocused($event)'
  [itemTemplate]="itemTemplate"
  [notFoundTemplate]="notFoundTemplate">                                 
</ng-autocomplete>

<ng-template #itemTemplate let-item>
<a [innerHTML]="item.name"></a>
</ng-template>

<ng-template #notFoundTemplate let-notFound>
<div [innerHTML]="notFound"></div>
</ng-template>
</div>
class TestComponent {
  keyword = 'name';
  data = [
     {
       id: 1,
       name: 'Usa'
     },
     {
       id: 2,
       name: 'England'
     }
  ];


  selectEvent(item) {
    // do something with selected item
  }

  onChangeSearch(val: string) {
    // fetch remote data from here
    // And reassign the 'data' which is binded to 'data' property.
  }
  
  onFocused(e){
    // do something when input is focused
  }
}

API

Inputs

Input Type Default Required Description
[data] Array<any> null yes Items array. It can be array of strings or array of objects.
searchKeyword string - yes Variable name to filter data with.
customFilter (items: any[], query: string) => any[] undefined no Custom filter function. You can use it to provide your own filtering function, as e.g. fuzzy-matching filtering, or to disable filtering at all (just pass (items) => items as a filter). Do not change the items argument given, return filtered list instead.
placeholder string - no HTML <input> placeholder text.
heading string - no Heading text of items list. If it is null then heading is hidden.
initialValue any _ no initial/default selected value.
focusFirst boolean false no Automatically focus the first matched item on the list.
historyIdentifier string _ no History identifier of history list. When valid history identifier is given, then component stores selected item to local storage of user's browser. If it is null then history is hidden. History list is visible if at least one history item is stored. History identifier must be unique.
historyHeading string Recently selected no Heading text of history list. If it is null then history heading is hidden.
historyListMaxNumber number 15 no Maximum number of items in the history list.
notFoundText string Not found no Set custom text when filter returns empty result.
isLoading boolean false no Set the loading state when data is being loaded.
minQueryLength number 1 no The minimum number of characters the user must type before a search is performed.
debounceTime number _ no Delay time while typing.
disabled boolean false no input disable/enable.
name string _ yes (If NgModel is used within a form tag) Tracks the name bound to the NgModel directive. For more details click here
[(ngModel)] any _ no Tracks the value bound to this directive. Used with Template-driven forms. For more details click here
[formControl] / formControlName string _ no Tracks the FormControl instance bound to the directive. Used with Reactive forms. For more details click here and here

Outputs

Output Description
(selected) Event is emitted when an item from the list is selected.
(inputChanged) Event is emitted when an input is changed.
(inputFocused) Event is emitted when an input is focused.
(inputCleared) Event is emitted when an input is cleared.
(opened) Event is emitted when the autocomplete panel is opened.
(closed) Event is emitted when the autocomplete panel is closed.
(scrolledToEnd) Event is emitted when scrolled to the end of items. Can be used for loading more items in chunks.

Methods (controls)

Name Description
open Opens the autocomplete panel
close Closes the autocomplete panel
focus Focuses the autocomplete input element
clear Clears the autocomplete input element

To access the control methods of the component you should use @ViewChild decorator. See the example below:

<ng-autocomplete #auto></ng-autocomplete>
class TestComponent {
  @ViewChild('auto') auto;

  openPanel(e): void {
    e.stopPropagation();
    this.auto.open();
  }
  
  closePanel(e): void {
    e.stopPropagation();
    this.auto.close();
    }
    
  focus(e): void {
    e.stopPropagation();
    this.auto.focus();
  }  
}

Styles

If you are not happy with default styles you can easily override them:

<div class="ng-autocomplete">
<ng-autocomplete></ng-autocomplete>
</div>
.ng-autocomplete {
    width: 400px;
}

Support Angular autocomplete!

If you do love angular-ng-autocomplete I would appreciate a donation :)

Author

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].