import {
// ...
ChangeDetectorRef
} from '@angular/core';
// ...
@Component({
// ...
})
export class AlbumComponent {
// ...
direction: string = null; // 🅰
// ...
constructor(private changeDetectorRef: ChangeDetectorRef) { } // 🅱
slide(offset) {
const nbPhotos = this.album.photos.length;
this.direction = (offset < 0) ? "right" : "left"; // 🅲
this.changeDetectorRef.detectChanges(); // 🅳
this.current = (((this.current + offset) % nbPhotos) + nbPhotos) % nbPhotos;
}
}