gpt4 book ai didi

javascript - ng-select 中 [clearable] 的替代方法是什么

转载 作者:行者123 更新时间:2023-12-05 05:12:29 24 4
gpt4 key购买 nike

我不想在 ng-select 中使用 [clearable] 来泄漏我的空间。而不是 [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>

最佳答案

如果您执行 [clearable]="false" 它将不允许清除选择。

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

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

并保持ng-select原样

Demo

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

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

关于javascript - ng-select 中 [clearable] 的替代方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54510458/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com