3

我不想用[clearable]inng-select来泄露我的空间。而不是[clearable]我只想使用[clearOnBackspace],但是当我写 它[clearable] = "false"[clearOnBackspace] = "true"它不起作用。

enter code here

    <ng-select [items]="cities"
               bindLabel="name"
               placeholder="Select city"
               [(ngModel)]="selectedCity"
               [clearable]="false"
               [clearOnBackspace] = "true"
               [excludeGroupsFromDefaultSelection] = "true">
    </ng-select>
4

1 回答 1

2

如果您这样做[clearable]="false",它将不允许清除选择。

您可以使用 css 隐藏关闭图标。像这样

.ng-clear-wrapper{
  display: none;
}

并保持ng-select原样

演示

<ng-select [items]="cities"
               bindLabel="name"
               placeholder="Select city"
               [(ngModel)]="selectedCity"
               [clearable]="true"
               [clearOnBackspace] = "true"
               [excludeGroupsFromDefaultSelection] = "true">

事实上你不需要[clearOnBackspace] = "true"

于 2019-02-04T05:52:10.257 回答