export class DatatableslibraryComponent implements OnInit, OnDestroy {
users$: any[] = [];
dtOptions: DataTables.Settings = {};
dtTrigger: Subject<any> = new Subject();
constructor(private http: HttpClient, private data: DataService) {
}
ngOnInit() {
this.dtOptions = {
pagingType: 'full_numbers',
pageLength: 5,
processing: true
};
this.data.getUsers().subscribe(data => {
this.users$ = data;
this.dtTrigger.next();
});
}
ngOnDestroy(): void {
this.dtTrigger.unsubscribe();
}
}