0

Below question is in angular 7

<header class="stick-top forsticky gradient">

Here is my html content in angular

current_path = localStorage.getItem("current_path");

current path is a variable in my component.

I wants to make if current_path != '/' in component then heder will be like this.

<header class="stick-top forsticky gradient">

else

<header class="stick-top forsticky">

I wants to remove gradient class from hrader tag if my current_path is '/'

0

2 Answers 2

4

you can use ngClass:

<header class="stick-top forsticky" [ngClass]="{'gradient':current_path != '/'}">
Sign up to request clarification or add additional context in comments.

Comments

2

If it is a single class, a good enough alternative to ngClass is

<header class="stick-top forsticky" [class.gradient]=" current_path != '/' " >

You may prefer this syntax since it is easier to format and prettify in the html templates than js objects that resolve to classes.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.