I'm using ngx-chips for a tag input control. I'm using my own custom objects as items to use in the control's dropdown; these have this structure:
_id: number;
name: string;
summary: string;
creationDate?: string;
lastUpdate?: string;
So as per ngx-chips documentation, I provide [identifyBy]="'_id'"
and [displayBy]="'name'"
as inputs to the control; now when I choose another item to add on the control and update the model, it gets added with all of its fields as listed above;
This is my input:
<tag-input [(ngModel)]="goalModel" [theme]="'wsm-theme'" [identifyBy]="'_id'" [displayBy]="'name'" [onlyFromAutocomplete]="true" [placeholder]="'Add filters'" class="wsm-input px-1 py-0">
<tag-input-dropdown [showDropdownIfEmpty]="true"
[autocompleteItems]="goalFilters"
[limitItemsTo]="4"
[identifyBy]="'_id'" [displayBy]="'name'">
</tag-input-dropdown>
</tag-input>
Is there some way to upon adding the item to only keep the _id
and name
fields on the model? I'm thinking it should be something done in the (onAdd)
output event of the control; but I can't think of a way to actually make this happen, if it can be done at all.