You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are the available Input properties you can pass to the component.
43
+
44
+
| Input | Type | Default | Description |
45
+
| ------ | ----- | -----| --------------- |
46
+
|`tagsData`|`any[]`|`[]`| List of items to be added in dropdown. Must be piped with async to pass an array. |
47
+
|`disabled`|`boolean`|`false`| Disables the component interactions. |
48
+
|`config`|[`AngularTagsInputConfig`](#angulartagsinputconfig)| (described in Interfaces section) | Component configuration (defined in [`AngularTagsInputConfig`](#angulartagsinputconfig) under [Configuration Interface](#configuration-interface)) |
49
+
|[`dropDownTemplate`](#dropdown-template-dropdowntemplate)|`TemplateRef<any>`| Built-in template | Template used for rendering the dropdown content. |
50
+
|[`tagItemTemplate`](#tag-item-template-tagitemtemplate)|`TemplateRef<any>`| Built-in template | Template used for rendering the tag item in field.|
51
+
52
+
## Ouput Events
53
+
54
+
These events are emitted by the component and can be subscribed to using Angular event binding syntax.
55
+
56
+
| Output | Payload Type | Description |
57
+
| -------------- | ------------- | -----------|
58
+
|`tagAdded`| Tag item object (original data + internal metadata) | Emitted when a new tag is added |
59
+
|`tagRemoved`| Tag item object (original data + internal metadata) | Emitted when a tag is removed |
60
+
|`valueChanged`|`string` d| Emit the value typed in input field |
61
+
|`itemClicked`| Tag item object (original data + internal metadata) | Emit when a tag is clicked. |
62
+
63
+
> **Note**: The emitted item in `tagAdded`, `tagRemoved` and `itemClicked` includes all properties of your original data object, along with additional internal fields used by the library (e.g., tiSelected, tiIdentifier, etc.).
64
+
65
+
## Configuration Interface
66
+
67
+
### AngularTagsInputConfig
68
+
69
+
This interface defines all configurable options available for the tags input component.
|`identifier`|`string`| Unique key used to identify each item in the provided `tagsData`. |
74
+
|`displayProperty`|`string`| Key in your `tagsData` whose value will be shown as the label for each dropdown option. |
75
+
|`showTooltipOnOptions`|`boolean`| Shows tooltip on hovering the dropdown options. Should be used together with `hoverProperty`. |
76
+
|`hoverProperty`|`string`| The value that will be displayed as tooltip. |
77
+
|`showTagsSelectedInDD`|`boolean`| Enable it if you want to show a check mark on selected items. |
78
+
|`hideAddedTags`|`boolean`| Enable it if you want to hide those tags that have already been selected in dropdown. |
79
+
|`placeholder`|`string`| The placeholder value for input field. |
80
+
|`additionalClasses`|`string`| Additional classes to style input field. |
81
+
|`hideDDOnTagSelect`|`boolean`| Enable it if you want to hide dropdown on every tag selection. |
82
+
|`toggleSelectionOnClick`|`boolean`| Allows selecting/deselecting a dropdown item on click; clicking an already-selected item removes it instead of adding again. |
83
+
|`clearInputOnFocus`|`boolean`| Allows you to erase the text, when you focus on the input field. |
84
+
|`clearTagsOnFocus`|`boolean`| Allows you to erase the tags, when you focus on the input field. |
85
+
|`ddHasBackdrop`|`boolean`| Adds a backdrop overlay behind the dropdown |
86
+
|`hideDDOnBlur`|`boolean`| Automatically hides the dropdown when the input field loses focus. Works only when ddHasBackdrop is disabled, because the backdrop prevents normal blur events. |
87
+
|`maxItems`|`number`| Specify the max number of tags that can be added inside input field. |
88
+
|`hideInputOnSelection`|`boolean`| Allows you to insert only one tag, as the input field disappears on tag selection. |
89
+
|`hideTags`|`boolean`| Allows you to hide the selected tags from the input field. |
90
+
91
+
If your data is nested, you may need to use these options as well.
|`childrenCountProperty`|`number`| Specifies the number of children an item have. |
96
+
|`nestedTagProperty`|`string`| The key in your `tagsData` that have the list of child items. |
97
+
|`nestedTagParentProp`|`string`| Speicifies the identifer of parent. |
98
+
|`showParentTagsOnly`|`boolean`| Enable it if you want to show only parent tag if all of its child tags are selected. Disable it if you want to show parent tags along with its child tags. |
99
+
100
+
## Custom Templates
101
+
102
+
The component allows you to fully customize the dropdown and tag appearance by passing your own Angular templates. If you don't pass `dropDownTemplate` or `tagItemTemplate`, the library would use its own default template.
103
+
104
+
### Dropdown Template (`dropDownTemplate`)
105
+
106
+
Example usages of `dropDownTemplate` are as follows:
> Always remember to add `(click)="fns.onItemClicked(item)"`, otherwise neither the item will be added in input field nor any event would be emitted on clicking item.
125
+
126
+
> Don't forget to add `tick.png` in your assets folder.
style="background: none; border: none; color: white; cursor: pointer; padding: 2px;">
196
+
x
197
+
</button>
198
+
</div>
199
+
</ng-template>
200
+
```
201
+
> Notice the `(click)="closeClicked.emit(item)"`. If you don't include this in button tag, then the tag won't be removed from input field upon clicking on cross button and you will have to remove the item by clicking on option from dropdown.
202
+
>
203
+
> If you don't want the cross button functionality, you can simply remove the `button` tag.
204
+
205
+
41
206
## Compatibility
42
207
43
208
All released versions of this library (up to tag `0.1.16`) are compatible with Angular `^8.2.11`.
44
209
45
210
Use `1.x.x` for Angular `^15.x.x`
211
+
212
+
## Development
213
+
214
+
### Build
215
+
216
+
Run `npm run build:lib` to build the library. The build artifactsqm will be stored in the `dist/` directory.
217
+
218
+
### Running unit tests
219
+
220
+
Run `npm test` to execute the unit tests via [Jest](https://jestjs.io/).
221
+
222
+
### Release
223
+
224
+
1. Bump the version in `projects/angular-tags-input/package.json`.
225
+
2. Run `npm install` to update `package-lock.json`.
226
+
3. Commit the changes.
227
+
4. Tag the release: `git tag -a v1.x.x -m "v1.x.x"` (e.g., `v1.1.0`).
228
+
5. Push changes and tags: `git push origin master --tags`.
229
+
6. Run `npm run release` to build and publish the library to npm.
230
+
231
+
## Demo
232
+
233
+
The demo application is located in `projects/tags-input-demo`.
234
+
235
+
### Running the demo
236
+
237
+
Run `npm start` to serve the demo application. Navigate to `http://localhost:4200/`.
238
+
239
+
### Deploying the demo
240
+
241
+
The demo is deployed to GitHub Pages using GitHub Actions.
242
+
To deploy manually:
243
+
1. Run `npm run build` to build the demo application.
244
+
2. Deploy the contents of `dist/tags-input-demo` to the `gh-pages` branch.
0 commit comments