angular ng-select and add event

Bogdan Tushevskyi picture Bogdan Tushevskyi · Jul 17, 2018 · Viewed 21.7k times · Source

I'm using ng-select and on selected item fire the callback which does some logic. I face the problem, that (add) event does not fire when I choose the item from the list and I use the (change) event instead. But if I use one item twice from the list the change event not fire, because it's a change event.

<ng-select 
    [clearSearchOnAdd]="true"
    (change)="changeLeagueOwner($event)"
    (add)="test()" ---> nothing here
    [clearable]="false"
    [items]="adminLeagueMembers"
    bindLabel="display_name">
</ng-select>

Answer

Arnaud P picture Arnaud P · Dec 17, 2020

Just for completion's sake, the reason why (add) is not working in your example is described in the documentation:

(add) is fired when item is added while [multiple]="true". Outputs added item