1.0.6 • Published 7 years ago

ionic2-tags-input v1.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Ionic2 Tags Input

Ionic 2 Module that allows to write the content in popular tags form.

Features

  • Custom labels and placeholders
  • Maximum length of word restriction
  • Maximum amount of items restriction
  • Prevent duplicates restriction
  • Callback fn after added or removed tag

Gif

Installation

1. Install the NPM Package

npm install --save ionic2-tags-input

2. Import TagsInputModule module into your app's module.

import { TagsInputModule } from 'ionic2-tags-input';

// import the module
@NgModule({
  ...
  imports: [
    TagsInputModule
  ]
})

Usage

Bind component to formControl or ngModel

<tags-input formControlName="animals"></tags-input>

Form structure

  public animals:FormGroup =  this.formBuilder.group({
    animals: [
        [
            {
                'name': 'Gazelle'
            },
            {
                'name': 'Cat'
            }
        ]
    ],
  });

@Inputs / Attributes

NameTypeDescriptionDefault Value
maxTagsnumberNumber of tags allowed. If maximum value is achieved, add button becomes disabledN/A
maxWordLengthnumberMaximum length of the word/sentenceN/A
allowDuplicatesbooleanAllow duplicatesfalse
buttonLabelstringAdd button labelAdd
alertTitleLabelstringThe title of alertAdd item
alertInputPlaceholderstringPlaceholder of the input inside the alert modalType text
alertButtonLabelstringLabel of the alert buttonOK
wordLengthRestrictionMsgstringText displayed if word is too longError: This word is too long
duplicatesRestrictionMsgstringText displayed if user is trying to make a duplicateError: Duplicates are not allowed

@Outputs

Attribute NameTypeDescription
onTagAddedfnCallback fn after added tag
onTagRemovedfnCallback fn after removed tag