You can use ngClass directive:
<div id="mydiv" [ngClass]="{'myCSSclass' : condition}"></div>
Simple as that! myDiv will have the class myCSSclass only when the condition evaluates to true. This condition can be set in your typescript file or in the template.