I am displaying a list of cards having questions and details related the questions and I want to show animation when I delete the question. The problem is when I am pressing delete button for one question, the sliding animation is being applied on all the cards (or questions). So please tell me that how can I apply animation only for the card which I deleted.
<div class="container" *ngIf="questionInfoList">
<mat-card *ngFor="let questionInfo of questionInfoList" [@removeAnimation]>
<button mat-icon-button title="delete this question" (click)="deleteQuestion(questionInfo[0])">
<mat-icon>delete</mat-icon>
</button>
</mat-card>
</div>
@Component({
selector: 'app-admin-questions',
templateUrl: './admin-questions.component.html',
styleUrls: ['./admin-questions.component.css'],
animations: [
trigger('removeAnimation', [
transition('* => void', [
animate('1s', style({
transform: 'translateX(100%)'
}))
])
])
]
})
export class AdminQuestionsComponent implements OnInit {
currentChannel!: string;
questionInfoList!: Array<Array<string>>;
constructor(private activeRouter: ActivatedRoute, private admin_service: AdminService, private snack: MatSnackBar,
private service: EndpointsService, private bottomSheet: MatBottomSheet)
deleteQuestion(questionId: string) {
const numericQuestionId = Number(questionId);
this.admin_service.deleteQuestion(numericQuestionId).subscribe({
next: response => {
this.snack.open(response, '', {
duration: 3000
})
},
error: err => console.log(err)
})
}
}
}