I need to increment a value in my program based on user input. The value should always match the input number provided by the user. To achieve this, I simply set the value equal to the inputValue.
Although I am able to retrieve the input value using @ViewChild, I'm facing an issue where every time I change the value, it loses focus and requires another click to select it again. I'm not sure why this is happening and how to resolve it, so any help would be appreciated. (I have no problem with refactoring if necessary)
Below is a simplified version of the code snippet:
<div *ngFor="let x of (myArray | async)">
<input (input)="myFunction()" [value]="x.value" #myInput type="number">
</div>
@ViewChield('myInput') myInput: ElementRef
myArray: Observable<Array<Object>>;
myFunction() {
this.store.dispatch(new Action(this.myInput.nativeElement.value));
}