Issue
I have used ngrx fromEvent operator to create an Observable from 2 input text fields, I have used document as target which is fine, but now I want to target only one input field. I am not sure sure what to use instead of document to target only one input field.
What I have done so far to get the target
- Used document.getElementByID('someID')
- Used ElementRef
- Used document.querySelector('someID')
Code
import { Component } from '@angular/core';
import { fromEvent } from 'rxjs';
@Component({
selector: 'my-app',
template: `<input type="text">
<input type="text">`
})
export class AppComponent {
ngOnInit() {
fromEvent(document, 'keyup')
.subscribe(res => console.log(res.target.value));
}
}
Thanks for your help in advance.