0.0.2 • Published 5 years ago

ngx-tags v0.0.2

Weekly downloads
74
License
MIT
Repository
github
Last release
5 years ago

NgxTags

Installation

To install this library, run:

$ npm install ngx-tags --save

Consuming the library

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import the library
import { NgxTagsModule} from 'ngx-tags';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify the library as an import
    NgxTagsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once the library is imported, you can use it in your code

...
<ngx-tags [options]="statesTags" [maxTags]="4" [(ngModel)]="defaultTags" [removeLastOnBackspace]="true" [canDeleteTags]="true" [canAddTags]="true" [allowDupes]="true" [onlyFromDropdown]="true"></ngx-tags>
...

API

KeyDefaultRemarks
ngModelN/AThe variable you wish to bind your tags to. Must be an Array
removeLastOnBackspacefalseBoolean indicating that you can remove the last tag in the row when you press backspace in the input area when it is empty
canDeleteTagstrueBoolean indicating wether tags can be removed or not
allowDupesfalseBoolean indicating weather tags can be duplicated
canAddTagstrueBoolean indicating wether tags can be added or not
placeholder'add a tag'Placeholder text to display when not tags are present
tagTemplateN/Apass the ngtemplate to render for each tag input
dropdownItemTemplateN/Apass the ngtemplate to render for each dropdown item
maxTagsN/Amaximum number tags allowed to select
onlyFromDropdownfalseonly avail selection from the dropdown
clearOnBlurtrueclear input when blured out
optionsN/Ashould be Array of objects
tagLabel'tagLabel'Name of the property to show in the dropdown,tag
readonlyfalseset tag to ready-only, should be added as prop to tag object
minLengthBeforeOptions1The length of the typed string before the dropdown is shown. Putting this to 0 will display it on focus
changeN/AWill be called when a change is made to the tags $event will have the following structure: {type: 'add', tag: {}} where type can be add , remove , delete orupdate

Development

Build the library

$ ng build ngx-tags

Run the demo app

$ ng serve

License

MIT © Waseem Bepari