Strict done!!
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
@@ -22,7 +22,7 @@ export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
dataSource: AccountListDataSource;
|
||||
filter: Observable<string>;
|
||||
form: FormGroup;
|
||||
list: Account[];
|
||||
list: Account[] = [];
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'type', 'isActive', 'isReconcilable', 'costCentre'];
|
||||
@@ -31,13 +31,13 @@ export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
this.form = this.fb.group({
|
||||
filter: '',
|
||||
});
|
||||
this.filter = this.listenToFilterChange();
|
||||
}
|
||||
|
||||
listenToFilterChange() {
|
||||
return this.form
|
||||
.get('filter')
|
||||
.valueChanges.pipe(startWith(''), debounceTime(150), distinctUntilChanged());
|
||||
// Listen to Filter Change
|
||||
this.filter = (this.form.get('filter') as FormControl).valueChanges.pipe(
|
||||
startWith(''),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
);
|
||||
this.dataSource = new AccountListDataSource(this.list, this.filter);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -46,12 +46,12 @@ export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
|
||||
this.list = data.list;
|
||||
});
|
||||
this.dataSource = new AccountListDataSource(this.paginator, this.sort, this.filter, this.list);
|
||||
this.dataSource = new AccountListDataSource(this.list, this.filter, this.paginator, this.sort);
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
this.filterElement.nativeElement.focus();
|
||||
if (this.filterElement) this.filterElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user