Dynamically updating css in Angular 2

Try this

 <div class="home-component" 
 [style.width.px]="width" 
 [style.height.px]="height">Some stuff in this div</div>

[Updated]:
To set in % use

[style.height.%]="height">Some stuff in this div</div>

Leave a Comment