Reputation: 12005
I tried this solution
It did not help me.
Code:
@ViewChild('filter') filteru: ElementRef;
ngAfterViewInit() {
this.dataSource = new ExampleDataSource(this.exampleDatabase);
Observable.fromEvent(this.filteru.nativeElement, 'keyup')
.debounceTime(150)
.distinctUntilChanged()
.subscribe(() => {
if (!this.dataSource) { return; }
this.dataSource.filter = this.filteru.nativeElement.value;
});
}
I import this:
import 'rxjs/add/observable/fromEvent';
Upvotes: 0
Views: 451
Reputation: 19622
I guess you might have missed the imports
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import {Observable} from 'rxjs/Observable';
Working Stackblitz link
Upvotes: 1