Reputation: 482
Hello like in the subject, I want to change the class of the item like this:
<a class="nav-link active" href="#"> --> <a class="nav-link" href="#">
Have you any ideas? Thanks for ur answer.
Upvotes: 0
Views: 305
Reputation: 4269
I am assuming you are using a condition to decide the classes you are going to apply to the element. You may use ngClass
directive to decide the classes to apply:
<a [ngClass]="{'nav-link active' : condition1, 'nav-link': condition2}" href="#">
Click here
</a>
The above is an example only. You may use this example to write to evaluate different expressions/conditions and apply one or more CSS classes.
Upvotes: 1
Reputation: 356
You can use ngClass directive:
<a class="nav-link" [ngClass]="{'active' : condition}" href="#">
Upvotes: 1
Reputation: 533
You can use the [class.] directive provided by angular like so:
<a class="nav-link" [class.active]"your-condition" href="#">
You can read more about this here: https://angular.io/guide/attribute-binding#binding-to-the-class-attribute.
Upvotes: 2