To add a conditional class in Angular we can pass an object tongClasswhere key is theclassnameandvalueis condition i.e., true or false as shown below. And in the above code, class name will be added only when the condition is true. We can add a single class or multiple classes dyn...
其中包含一个像变量一样的对象的属性,这提醒我到目前为止还不能使用[with][3]语句--您不能使用with...
In web apps it's a common requirement to tailor an element's appearance based on a condition. There are a few ways of accomplishing this, but if you're working with Angular, your choice is clear. The ngClass directive provides a myriad of ways to dynamically assign class names to element...
另见https://angular.io/docs/ts/latest/api/common/index/NgClass-directive.html <some-element [ngClass]="'first second'">...</some-element> <some-element [ngClass]="['first', 'second']">...</some-element> <some-element [ngClass]="{'first': true, 'second': true, 'third': fal...