Control slide number
To open the gallery on a different slide than the first, specify the desired slide by using one of the two props: "slide" (integer) or "sourceIndex" (integer, slide number minus one).
import { Component } from "@angular/core";
import { FsLightbox } from "fslightbox-angular";
@Component({
selector: 'app-root',
imports: [FsLightbox],
template: `<div>
<fslightbox
[toggler]="toggler"
[sources]="sources"
[slide]="slide"
/>
<button (click)="openLightboxOnSlide(1)">
Open the lightbox on the first slide
</button>
<button (click)="openLightboxOnSlide(2)">
Open the lightbox on the second slide
</button>
</div>`
})
export class App {
toggler = false;
slide = 1;
sources = [
'/Images/1.jpg',
'/Images/2.jpg'
];
openLightboxOnSlide(slide : number) {
this.slide = slide;
this.toggler = !this.toggler
}
}In the above example, there is presented a usage of the "slide" prop. The other prop—"sourceIndex"—is used analogously.