我不想使用[clearable]
中的ng-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>
答案 0 :(得分:0)
如果您执行[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"