I am trying to increment a value of my program using an input number. For reasons, I need my value to always be equal to the one in the Input.
My action is basically just doing value = inputValue
.
I managed to get my Input value using @ViewChild
, but everytime I change its value, it lose focus and I need to click on it again. I have no clue why it is happening and how to fix it, hope you can help me guys ! (Refactoring isn't a problem)
Following is a very simplified version of my code.
<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));
}