user12299366
user12299366

Reputation:

Add and remove classes Angular without controller

I have just started a new project with angular and I learnt abount *ngIf. I would like to use *ngIf in order to add / remove a class from a div

Before click

<div class="done">Foo</div>

After click

<div class="notdone">Foo</div>

Upvotes: 1

Views: 57

Answers (1)

Jo&#227;o Ghignatti
Jo&#227;o Ghignatti

Reputation: 2391

You have different ways of approaching this.

<div [ngClass]="{'done': conditionToDone, 'notdone': !conditionToDone}">Foo</div>

Where done or notdone are added via a condition.

Upvotes: 1

Related Questions