I am getting 5000 images from the backend. I images need to be lazy-loaded and I have watched some videos and implemented ng-lazyload-image module but it's not working as expected and My page is getting crash every time after few seconds and also that tab lagging very much.I supposed to do like this
i tried doing this
albums:any[];
photos:any[];
defaultImage = 'https://www.placecage.com/1000/1000';
offset = 50;
constructor(private service: AlbumService) { }
ngOnInit() {
this.list()
this.pics()
}
list() {
this.service.getAlbums().subscribe(res => {
this.albums = res;
console.log(this.albums)
});
}
pics() {
this.service.getPhotos().subscribe(res => {
this.photos = res;
console.log(this.photos)
});
}
}
<div class="card" *ngFor="let album of albums">
<div class="card-body">
<h5 class="card-title">{{album.title}}</h5>
<h6 class="card-subtitle mb-2 text-muted">id:{{album.id}},userid:{{album.userId}}</h6>
<div class="container carousel-inner no-padding" *ngFor="let photo of photos">
<div class="carousel-item active">
<div class="col-xs-3 col-sm-3 col-md-3">
<img [lazyLoad]="photo['url']" [defaultImage]="defaultImage" [offset]="offset">
</div>
</div>
</div>