11

I want to calculate div height based on the component value by using calc CSS function. The error it gave me:

TypeError: co.calc is not a function

My code:

<div [ngStyle]="{'height': calc(100% - + assetScreenSize + px)}">
</div>
Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
PARAMANANDA PRADHAN
  • 1,104
  • 1
  • 14
  • 23

1 Answers1

10

Your syntax is incorrect. The correct way would be:

<div [ngStyle]="{'height': 'calc(100% -' + assetScreenSize + 'px)'}">
</div>
Aslam
  • 9,204
  • 4
  • 35
  • 51
  • You have an extra quote. It should be {'height': 'calc(100% -' + assetScreenSize + 'px)'} – mila Feb 17 '19 at 21:37