Hammer
Hammer

Reputation: 8888

Change class of DOM element using ngClass

In Angular2, I want to change the class of tr to 'success' if video.encodings.length>0. It seems the following does not work. The expression of ngClass can bind to data var?

 <tr *ngFor="#video of _videos" [ngClass]="success : {{ video.encodings.length >0 }}">
  </tr>

Upvotes: 0

Views: 239

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 658225

The syntax for ngClass should be

<tr *ngFor="#video of _videos" [ngClass]="{success : video.encodings.length > 0 }">

Upvotes: 1

Related Questions