简体   繁体   中英

@ng-select/ng-select show dropdown on typing

我正在使用ng-select,我正在执行一个多选下拉列表,所有内容均正常运行,但我想进行一些更改,我想在用户开始键入某些内容时显示下拉列表,并仅在文本框中显示用户键入内容上的过滤数据。

I hope below logic can helpful,

.HTML

<ng-select #elem [items]="cities2"
               bindLabel="name"
               bindValue="id"
               [multiple]="true"
               placeholder="Select cities"
               [(ngModel)]="selectedCityIds"
               (open)="onOpen(elem)">

.TS

onOpen(elem){
 if(elem.filterInput.nativeElement.value == ""){
   elem.close();
 }
}

If you want to hide drop-down toggle ( V ), you need to add style in parent component/file.

Index.html

<style>
    .ng-select .ng-arrow-wrapper {
        display: none !important;
    }
</style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM