I am new in angular 4. I want to implement scroll pagination in angular 4. Initially I want to show 20 records. After scroll down I want to show next 20. I will do the same till end of list.
I tried to implement it using "angular2-infinite-scroll". but I am not able to show initially first 20 records as well scroll data.
component file :
import { Component, OnInit } from '@angular/core';
import { InfiniteScrollModule } from 'angular2-infinite-scroll';
@Component({
selector: 'app-scroll',
templateUrl: `./scroll.component.html`,
styleUrls: ['./scroll.component.css']
})
export class ScrollComponent implements OnInit {
let item = [{
"Name": "XYz Compnay"
},
{
"Name": "XYz Company1"
}, {
"Name": "XYz Company2"
}, {
"Name": "XYz Company3"
}, {
"Name": "XYz Company4"
}, {
"Name": "XYz Company5"
}];
constructor() {}
ngOnInit() {}
onScroll () {
alert('scrolled!!');
}
}
HTML file :
<div
infinite-scroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="10"
(scrolled)="onScroll()"
>
<p *ngFor="let items of item">
{{items.Name}}
</p>
</div>
If anyone having about it please share same.