0

I am setting width of a div dynamically via angular variable. Here is my template looks like:

<nav class="navbar-dark" 
[ngClass]="isDefault() ? 'navbar-original': 'navbar'"
[ngStyle]="{ 'margin-left.px': navbarMargin, 'width.px': 'calc(100% - ' + navbarMargin + 'px)' }">

In here, margin-left is working fine but width is not updating.

Tried

[style.width.%]="sanitizer.bypassSecurityTrustStyle('calc(100% - 80px)')"

and

[ngStyle]="{'width.px': width}"

and various combinations of these. Nothing is updating width.

What exactly I am missing?

KAsh
  • 304
  • 5
  • 23

1 Answers1

1

Have you tried simply using [style.width]? "calc(100%- 80px)" is a string after all and [style.width.px] expects a number.

mk1x86
  • 158
  • 4