0

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.

IvanS95
  • 5,364
  • 4
  • 24
  • 62
  • Are the other properties `summary`, `creationDate`, and `lastUpdate` used anywhere on your component? – wentjun Aug 17 '19 at 03:41
  • Not on this component specifically, I may use them on a different one, but I just make a request to fetch all that data; for this component I only need `name` and `id` – IvanS95 Aug 17 '19 at 15:18

0 Answers0