How to clear ng-select selection

前端 未结 8 1290
孤街浪徒
孤街浪徒 2021-02-19 07:21

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

8条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 07:48

    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.

提交回复
热议问题