Is it possible to programmatically clear the selection of an ng-select dropdown? I'm wanting the equivalent behaviour of clicking the clear icon, but triggered programmatically.
I was expecting a clear()
method or something similar, but the documented API doesn't have anything along those lines.
This is my dropdown code:
<ng-select class="ng-select-wrap"
[searchFn]="multiTermSearch"
[items]="calculationOptions"
placeholder="Please select..."
name="calculation"
#calculationValue="ngModel"
[(ngModel)]="selectedCalculation">
</ng-select>
Agree with @tim and @AlexOnozor, I have successfully used 'selectedCalculation' as 'string', 'string[]', 'object[]' with Reactive Forms ( and as 'string' with ngModel ) and your suggested method worked smoothly. I also tried using 'handleClearClick' but failed. Will update if i find my way through it.
So, this.selectedCalculation = '' or this.selectedCalculation= [] (for multipleSelect = true) should work.