Reputation: 95
With Angular 2, what is the syntax to add an element property only if a condition is met. I was thinking of using *ngIf but it just adds or removes the entire element.
Upvotes: 1
Views: 1098
Reputation: 2936
Depends on the property.
The general syntax is [property]="value or condition"
.
For example:
[class.myclass]="condition" [style.height]="value" [selected]="condition"
Where condition and value are javascript expressions. Google for "Angular 2 template syntax".
Upvotes: 2