Teleskop
Teleskop

Reputation: 11

How to know selected div ? Angular

I need to know which div is selected. Check my code:

        <divdsadsadasda


toggle(i) {
console.log(i) // i got index
}

I need to know which div is selected and return values from clicked item.

Upvotes: 0

Views: 143

Answers (1)

KShewengger
KShewengger

Reputation: 8269

Instead of (click)="toggle(i)" replace it with (click)="toggle(training)" tht way you'll know which of the trainingExercises was selected.

<div *ngFor="let training of data.trainingExercises; let i = index;">
     ...

     <div (click)="toggle(training)">
        ...
     </div>

  
</div>

Upvotes: 1

Related Questions