Can anyone tell my this works
[style.height]="events?.length === 0 ? 'calc(100vh - 105px)' : null"
but this doesn't?
[ngStyle]="{'height: calc(100vh - 105px)': events?.length === 0 }"
or this?
[style.height]="{'calc(100vh - 105px)': events?.length === 0 }"
On ngStyle, you need to put the style attribute with values as
jsondata. On thatjsondata, the key shouldstylename and the value should be the css attribute value as follows.But on your code,
You have put the full
[style name]: [style value]as the key onjsondata and it won't work onngStyle.And
[style.height]indicates theheightcss attribute onstylehtml attribute. So[style.height]="'100px'"has the same meaning withstyle="height: 100px;".And on this code,
You have put
jsonobject intostyle.heightand this is not acceptable asheightcss attribute value so it's not working.