here
@Component({
...
animations: [trigger("fade", [ // fade animation
state("void", style({ opacity: 0 })),
transition("void <=> *", [animate("0.5s ease-in-out")])
])]
}).
showNextImage() {
if (this.counter < this.slideItems.length -1) {
this.counter += 1;
}
}
showPreviousImage() {
if (this.counter >= 1) {
this.counter = this.counter - 1;
}
}
<ul>
<li *ngFor="let item of slideItems;let i = index">
<img *ngIf="i == counter" @fade [src]="slideItems[i].src" alt="item.title">
</li>
</ul>
stackblitz preview