我在项目中使用了ng-select
,使用[clearable]="false"
删除了清除十字图标,还通过覆盖ng-value-icon
类删除了每个项的清除图标
:host ::ng-deep .ng-value-icon {
display: none !important;
}
我想要应用有条件的css
constructor() {
if(this.result === "ok") {
//apply the css
}
}
发布于 2020-12-17 18:30:29
模板的这一部分(来自Stackblitz)决定类custom
与名为step
的作用域变量相关
[class.custom]="step === 'step1'"
所以,使用它:
step: 'step1'|'not-step1' = 'not-step1';
constructor() {
if(this.result === "ok") {
this.step = "step1";
}
}
或者将模板中的条件更改为
[class.custom]='result === "ok"'
或者,比这个css切换更好的方法是,您可以使用*ngIf
*ngIf="result === 'ok'"
。
https://stackoverflow.com/questions/65337902
复制相似问题