我不想在下拉列表中显示已启用属性设置为false的值。
<ng-select placeholder="Select" *ngIf="test.test.type == 'test1'">
<ng-option *ngFor="let testValue of test.values"
[value]="testValue" [disabled]="testValue.enabled === false" >{{testValue.value}}</ng-option>
</ng-select> 以上代码禁用已启用属性设置为false的值。如何过滤这些选项,以便在不删除数组项的情况下从下拉列表中完全删除禁用的选项。
提前谢谢。
发布于 2021-01-15 09:14:33
下面的代码工作了
.ng-select.custom-class .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-disabled {
display: none !important;
}发布于 2021-01-15 09:06:12
你可以使用CSS。下面的代码将帮助您在下拉列表中添加隐藏类,并且可以根据expr隐藏值,前提是必须计算为true。
<ng-select placeholder="Select" *ngIf="test.test.type == 'test1'">
<ng-option *ngFor="let testValue of test.values"
[value]="testValue" [disabled]="testValue.enabled === false" [class.hidden]="Write an expr for which you need to hide" >{{testValue.value}}</ng-option>
</ng-select> 在您的组件css中:
.hidden {
visibility: hidden;
}https://stackoverflow.com/questions/65733069
复制相似问题