0

I am trying to make a width: calc() but i want to make a substract of 2 variables with different units but it doesnt show expected output.

[ngStyle]="{ 'width': calc(notHedgedProgress + '%' - newPositionX + 'px') }"

NotHedgedProgress and NewPositionX are numbers

as you can see im trying to substract a '%' unit variable with a 'px' one.

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Castle
  • 417
  • 3
  • 17

1 Answers1

4

Your variables has to be interpolated and the style rule must be in the form of a string:

[ngStyle]="{ 'width': 'calc(' + notHedgedProgress + '% - ' + newPositionX + 'px)' }"
eosterberg
  • 1,422
  • 11
  • 11