Currently, I am utilizing the angular2-swing library and have integrated the following code into my template:
<ul class="stack" swing-stack [stackConfig]="stackConfig" #myswing1 (throwout)="onThrowOut($event)">
<li swing-card #restaurantCards [ngClass]="restaurant.restaurant" *ngFor="let restaurant of restaurants">
<app-restaurant-card [restaurant]=restaurant.restaurant>
</app-restaurant-card>
<div class="overlay">
YUM!
</div>
</li>
</ul>
The following is the onThrowOut($event)
method:
onThrowOut(event: ThrowEvent) {
if(event.throwDirection == Direction.RIGHT){
this.restaurantService.addToLikes(event.target.getAttribute('ngClass'))
}
//hide element once thrown out
event.target.setAttribute("style", "visibility: hidden; transition: .1s; ");
}
Unfortunately, when attempting to retrieve the attribute, it returns null. Is there a way to access the element from within the for loop? Thank you