
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
ng2-tag-input
Advanced tools
This is a component for Angular 2. Design and API are blandly inspired by Angular Material's md-chips.
Check out the live dem (with source code) here http://www.webpackbin.com/VkRLliDHW.
npm install ng2-tag-input --save
npm test
Once installed, import the TagInput component and use it in your container component:
import { TagInput } from 'ng2-tag-input';
import { Component } from '@angular2/core';
@Component({
selector: 'app',
directives: [TagInput],
template: `<tag-input [(ngModel)]='items'></tag-input>`
});
export class App {
items = ['Pizza', 'Pasta', 'Parmesan'];
// ...
}
@Input
placeholder
- (?string
) - String that sets the placeholder of the input for entering new terms.secondaryPlaceholder
- (?string
) - String that sets the placeholder of the input for entering new terms when there are 0 items entered.maxItems
- (?number
) - Sets the maximum number of items it is possible to enter.readonly
- (?boolean
) - Sets the tag input static, not allowing deletion/addition of the items entered.separatorKeys
- (?string[]
) - Array of keyboard keys with which is possible to define the key for separating terms. By default. only Enter is the defined key.transform
- (?(item: string) => string
) - a function that takes as argument the value of an item, and returns a string with the new value when appended. If the method returns null/undefined/false, the item gets rejected.validators
- (?Validators[]
) - an array of Validators (custom or Angular's) that will validate the tag before adding it to the list of items. It is possible to use multiple validators.@Output
onAdd
- (onAdd(item: string)
) - event fired when an item has been addedonRemove
- (onRemove(item: string)
) - event fired when an item has been removedonSelect
- (onSelect(item: string)
) - event fired when an item has been selectedBasic examples:
// example app
@Component({
selector: 'app',
directives: [TagInput],
template: `<tag-input [(ngModel)]='items'></tag-input>`
});
export class App {
items = ['Pizza', 'Pasta', 'Parmesan'];
options = {
placeholder: "+ term",
secondaryPlaceholder: "Enter a new term",
separatorKeys: [4, 5]
maxItems: 10
}
onItemAdded(item) {
console.log(``${item} has been added`)
}
onItemRemoved(item) {
console.log(``${item} has been removed :(`)
}
// ...
}
<tag-input [(ngModel)]='items'
[placeholder]="options.placeholder"
[secondaryPlaceholder]="options.secondaryPlaceholder"
[maxItems]="options.maxItems"
[separatorKeys]="options.separatorKeys">
</tag-input>
<tag-input [(ngModel)]='items'
(onRemove)="onItemRemoved($event)"
(onAdd)="onItemAdded($event)">
</tag-input>
If you want to see more advanced examples, please have a look at http://www.webpackbin.com/VkRLliDHW.
FAQs
Tag Input component for Angular
The npm package ng2-tag-input receives a total of 66 weekly downloads. As such, ng2-tag-input popularity was classified as not popular.
We found that ng2-tag-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.