Angular 4 - Conditional CSS Classes
Answer :
You can do this using the class binding:
<input type="email" class="form-control" [class.error-field]="error">
yeah there's a better way using ngClass
attribute like this:
<input type="email" [ngClass]="{'form-control': true, 'error-field': error}" />
I believe you are looking for NgClass or NgStyle: https://angular.io/api/common/NgClass https://angular.io/api/common/NgStyle
Comments
Post a Comment