2

I want to implement PrimeNG DataTable LazyLoading in Angular 2 but there is no realtime example i found on internet.

I have already referred below PrimeNG site which shows lazy loading with dummy data: https://www.primefaces.org/primeng/#/datatable/lazy

Has anyone implemented by calling BE service? Please help.

1 Answers1

1

You need to add a service for this if you use angular cli you can add with

ng generate service services/CarService

after that you need to call service (maybe web api) then you need to inject your service to you lazy load component

constructor(private carService: CarService) { } 

then you can use your lazyload datatable. In this example your web api need to return data cars and totalcars(for pagination)

this.carService.getCarsLarge().then(cars => {
            this.datasource = cars; 
            this.totalRecords = this.datasource.length;
            this.cars = this.datasource.slice(0, 10);
        });
sonertbnc
  • 1,580
  • 16
  • 26
  • Thanks @Snr for your reply. I was expecting a realtime example which is not mentioned in PrimeNG DataTable documentation. Do you know any such example? That would be really helpful. – Prashant.patil Aug 14 '17 at 10:43