I've coded this html:
<p-table #usersTable ...>
<p-table>
I'm trying to pick up this element in order to create an observable on onLazyLoad
event:
@ViewChild('usersTable')
private usersTable: ElementRef;
In order to create observable:
public ngAfterViewInit() {
let lazyTable$ = Observable
.fromEvent(this.usersTable.nativeElement, 'onLazyLoad')
.pipe(debounceTime(300));
}
Nevertheless, this.usersTable
is undefined.
By other hand, I not sure at all, of having observable event creation correctly.
I've used
@ViewChildren(DataTable) private usersTable: QueryList<DataTable>;
Nevertheless, when a change is made query.length
is always 0:
let lazyClick$ = this.usersTable.changes
.pipe(
filter((query: QueryList<DataTable>) => {
return query.length > 0;
}),
map((query: QueryList<DataTable>) => {
return query.first;
}),
switchMap((table) => {
return table.onLazyLoad.asObservable();
})
);
Any ideas?