How to clear ng-select selection

前端 未结 8 1259
孤街浪徒
孤街浪徒 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:43

    Clearing the selection can be achieved by simply setting the ngModel value to null. In the case of the above example:

    this.selectedCalculation = null;
    

    This isn't exactly the same as clicking the clear icon, as it doesn't trigger the (clear) output event, but it was sufficient for my needs.

提交回复
热议问题