解析器错误:条件表达式需要所有3个表达式

17 浏览
0 Comments

解析器错误:条件表达式需要所有3个表达式

我的Angular代码有什么问题?我收到了以下错误:

“无法读取未定义的属性\'remove\',在BrowserDomAdapter.removeClass”

    1. Step1

 

    1. Step2

 

    1. Step3

 

 

admin 更改状态以发布 2023年5月23日
0
0 Comments

[ngClass]=...代替*ngClass

*仅用于结构指令的速记语法,您可以例如使用:

{{item}}

而不是更长的等效版本


另请参见https://angular.io/docs/ts/latest/api/common/index/NgClass-directive.html

...
...
...
...
...

另请参见https://angular.io/docs/ts/latest/guide/template-syntax.html


The class binding is special

This one is not so special


Bad curly

0
0 Comments

Angular 2+版本提供了几种有条件地添加类的方法:

第一种方式

    [class.my_class] = "step === 'step1'"

第二种方式

    [ngClass]="{'my_class': step === 'step1'}"

以及多种选项:

    [ngClass]="{'my_class': step === 'step1', 'my_class2' : step === 'step2' }"

第三种方式

    [ngClass]="{1 : 'my_class1', 2 : 'my_class2', 3 : 'my_class4'}[step]"

第四种方式

    [ngClass]="step == 'step1' ? 'my_class1' : 'my_class2'"


你可以在文档页面中找到这些示例。

0