Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# angular2-tag-input
# angular2-tags
Tag input component for Angular 2

## Demo & Examples
[View Demo](http://www.webpackbin.com/EkDO0p3Ab)
#update
Updated to angular4

Added maxSize

## Quick Start
```
npm install angular2-tag-input --save
npm install angular2-tags --save
```

```
Expand Down Expand Up @@ -40,6 +42,7 @@ export class YourModule {}
| `autocompleteMustMatch` | `boolean` | `true` | Whether a tag must be present in the suggestions list to be valid |
| `autocompleteSelectFirstItem` | `boolean` | `true` | Pre-highlight the first item in the suggestions list |
| `placeholder` | `string` | `'Add a tag'` | Placeholder for the `<input>` tag. |
| `maxSize` | `number` | `''` | Sets a max number of tags. |


### Outputs
Expand Down
8 changes: 6 additions & 2 deletions lib/components/tag-input/tag-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface AutoCompleteItem {
(tagRemoved)="_removeTag($event)"
*ngFor="let tag of tagsList; let index = index">
</rl-tag-input-item>
<form [formGroup]="tagInputForm" class="ng2-tag-input-form">
<form [formGroup]="tagInputForm" class="ng2-tag-input-form" *ngIf="showForm()">
<input
class="ng2-tag-input-field"
type="text"
Expand Down Expand Up @@ -116,6 +116,7 @@ export class TagInputComponent implements ControlValueAccessor, OnDestroy, OnIni
@Input() autocompleteSelectFirstItem: boolean = true;
@Input() pasteSplitPattern: string = ',';
@Input() placeholder: string = 'Add a tag';
@Input() maxSize: number;
@Output('addTag') addTag: EventEmitter<string> = new EventEmitter<string>();
@Output('removeTag') removeTag: EventEmitter<string> = new EventEmitter<string>();
@ViewChild('tagInputElement') tagInputElement: ElementRef;
Expand Down Expand Up @@ -241,6 +242,10 @@ export class TagInputComponent implements ControlValueAccessor, OnDestroy, OnIni
);
}

public showForm(): boolean {
return (this.maxSize == undefined) || (this.tagsList.length < this.maxSize);
}

private _splitString(tagString: string): string[] {
tagString = tagString.trim();
let tags = tagString.split(this.splitRegExp);
Expand Down Expand Up @@ -273,7 +278,6 @@ export class TagInputComponent implements ControlValueAccessor, OnDestroy, OnIni
.filter(tag => this._isTagValid(tag))
.filter((tag, index, tagArray) => tagArray.indexOf(tag) === index)
.filter(tag => (this.showAutocomplete() && this.autocompleteMustMatch) ? this._isTagAutocompleteItem(tag) : true);

this.tagsList = this.tagsList.concat(validTags);
this._resetSelected();
this._resetInput();
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular2-tag-input",
"version": "1.2.3",
"description": "Tag input component for Angular 2",
"name": "angular2-tags",
"version": "1.0.4",
"description": "A fork from angular2-tag-input",
"main": "dist/index.js",
"keywords": [
"angular2",
Expand All @@ -18,22 +18,22 @@
"serve": "webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base demo/",
"lint": "tslint lib/**.*.ts"
},
"author": "TEAM COOL",
"author": "Ivan Joaquim",
"license": "ISC",
"peerDependencies": {
"@angular/common": "2.2.4",
"@angular/core": "2.2.4",
"@angular/forms": "2.2.4"
"@angular/common": "^2.4.7 || ^4.0.0",
"@angular/core": "^2.4.7 || ^4.0.0",
"@angular/forms": "^2.4.7 || ^4.0.0"
},
"devDependencies": {
"@angular/common": "2.2.4",
"@angular/compiler": "2.2.4",
"@angular/compiler-cli": "2.2.4",
"@angular/core": "2.2.4",
"@angular/forms": "2.2.4",
"@angular/platform-browser": "2.2.4",
"@angular/platform-browser-dynamic": "2.2.4",
"@angular/platform-server": "2.2.4",
"@angular/common": "^2.4.7 || ^4.0.0",
"@angular/compiler": "^2.4.7 || ^4.0.0",
"@angular/compiler-cli": "^2.4.7 || ^4.0.0",
"@angular/core": "^2.4.7 || ^4.0.0",
"@angular/forms": "^2.4.7 || ^4.0.0",
"@angular/platform-browser": "^2.4.7 || ^4.0.0",
"@angular/platform-browser-dynamic": "^2.4.7 || ^4.0.0",
"@angular/platform-server": "^2.4.7 || ^4.0.0",
"@types/node": "^6.0.45",
"awesome-typescript-loader": "^2.2.3",
"codelyzer": "~0.0.26",
Expand All @@ -46,7 +46,7 @@
"sass-loader": "^4.0.2",
"source-map-loader": "^0.1.5",
"tslint": "3.13.0",
"typescript": "2.0.10",
"typescript": "^2.0.10",
"webpack": "^2.1.0-beta.21",
"webpack-dev-server": "^2.1.0-beta.0",
"zone.js": "^0.6.25"
Expand Down