0

This is Angular 8 related question. not angular JS where declarations/syntax is different.

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?

0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.