DeepCode00

fromEvent

Nov 7th, 2020 (edited)
2,503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   @ViewChild('inputSearch') inputSearch: ElementRef;
  2.  
  3.   ngAfterViewInit(): void {
  4.     fromEvent(this.inputSearch.nativeElement, 'keypress').pipe(
  5.       map((el: KeyboardEvent) => el),
  6.       debounceTime(500),
  7.       distinctUntilChanged()
  8.     ).subscribe((el2) => console.log(el2.target.value));
  9.   }
Advertisement
Add Comment
Please, Sign In to add comment