An Ionic 2 module that lets users enter and manage values in a tag/chip style UI.
- Custom labels and placeholders
- Maximum tag length restriction
- Maximum number of tags restriction
- Optional duplicate prevention
- Callbacks when a tag is added or removed
npm install --save ionic2-tags-input
import { TagsInputModule } from 'ionic2-tags-input';
@NgModule({
...
imports: [
TagsInputModule
]
})Bind the component to a FormControl/formControlName (Reactive Forms) or ngModel.
<tags-input formControlName="animals"></tags-input>The component value is an array of objects shaped like { name: string }.
Reactive Forms example:
public form: FormGroup = this.formBuilder.group({
animals: [[
{ name: 'Gazelle' },
{ name: 'Cat' }
]]
});| Name | Type | Description | Default Value |
|---|---|---|---|
| maxTags | number | Number of tags allowed. If maximum value is achieved, add button becomes disabled | N/A |
| maxWordLength | number | Maximum length of the word/sentence | N/A |
| allowDuplicates | boolean | Allow duplicates | false |
| buttonLabel | string | Add button label | Add |
| alertTitleLabel | string | The title of alert | Add item |
| alertInputPlaceholder | string | Placeholder of the input inside the alert modal | Type text |
| alertButtonLabel | string | Label of the alert button | OK |
| wordLengthRestrictionMsg | string | Text displayed if word is too long | Error: This word is too long |
| duplicatesRestrictionMsg | string | Text displayed if user is trying to make a duplicate | Error: Duplicates are not allowed |
| Name | Type | Description |
|---|---|---|
| onTagAdded | EventEmitter | Emitted after a tag is added |
| onTagRemoved | EventEmitter | Emitted after a tag is removed |
