1.0.6 • Published 4 years ago

chip-autocomplete v1.0.6

Weekly downloads
30
License
MIT
Repository
github
Last release
4 years ago

ChipAutocomplete

Angular chip-autocomplete is a Formcontrol where you can create chips with autocomplete with clientside and server side option filtering which can be used with Reactive Forms as a normal formcontrol like <input> <select>

Demo

check out Live Demo

code: stackblitz

Getting Started

npm i chip-autocomplete

Configuration

Install @angular/material, if you didn't installed already:

npm add @angular/material

Ensure you import the module and the dependencies:

import { ChipAutocompleteModule } from 'chips-autocomplete';
import { BrowserModule } from '@angular/platform-browser'; 
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

@NgModule({
   imports: [
       BrowserModule,
       FormsModule,
       ReactiveFormsModule,
       ChipAutocompleteModule
       ...OtherModules 
   ] // along with your other modules
})
export class AppModule {}

Implementation

Use the component in any component:

app.component.html

<chip-autocomplete><chip-autocomplete>

You don't need <mat-form-field> around this control. It was given under the hood.

API

FeaturesTypeDefaultDescription
placeholderstring'Select'String that sets the placeholder
maxItemsnumbernullSets the maximum number of chips
removablebooleantruewhether the chips are removable
requiredbooleantruewhether the field is required
clientSideFilterbooleantruewhether the dropdown is filtered by client side or server side. If the value is true (clientside), options is required. If the value is false (serverside), filteredOptions$ Observable and isOptionString, changeSearchKey eventEmitter
optionsArraydropdown Options: Array of strings Or Array of Object
isOptionStringbooleantrueWhether the options are Strings or Object. In Cleint side filtering, it is not required, it can select automatically from options. But in server side filtering, it is required.
displayWithstring'value'If the options are objects, display property of that objects is required
itemIdstring'key'if the options are objects, key property of that objects is required
filteredOptions$Observable<any[]>Observable that fetch filtered Options from the server. It is required if it is server side filtering
changeSearchKeyEventEmitterEventemitter with every key stroke, useful for server side filtering
debounceTimenumber500DebounceTime for server side filtering
isChipAddFromInputbooleanfalsewhether the text not found in dropdown is allowed to add to chips
isOptionCheckablebooleanfalsewhether Options can be added to chips with checkbox
disabledSelectedbooleantrueWhether previously selected options will be disabled and prevent to select
1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago