AMALRAJ K V AMALRAJ K V - 4 years ago 152
AngularJS Question

Angular2 (v2.4.6) - Unable to bind data [style.height]="300"

First of all thank you for help ,

I just downloaded angular-Cli and made a project - angular2 Version 2.4.6

Everything works fine except, I am not able to use Style Binding directly in HTML, My code is working fine with angular 2.2 Version, don't know what exactly happened in new version

<div [style.width]="MYWIDTH" [style.height]="900" style="background-color: red" >
Hello
</div>


not working:
[style.width]="MYWIDTH" [style.height]="900"

Answer Source

Use [style.height.px]="900" or [style.height]="'900px'".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download