I'm struggling with Angular's reactive form valueChanges event. I want to react to user inputs in order to prevent or correct them, but every approach I've tried so far has resulted in a Maximum call stack size exceeded
error when subscribing to the event.
const controlArray = <FormArray> this.formArray.get('items');
this.formArray.get('items').valueChanges.subscribe(val => {
val.forEach(s => {
controlArray.controls.forEach(control => {
const con = control.get('symbol');
if (con.value === s.symbol) {
con.setValue(s.symbol.toUpperCase());
}
});
});
});
My ultimate goal is to change each letter input to uppercase. Is there a simpler way to achieve this without iterating through each keyboard event?
I also attempted using (change)="function(value)"
, but it only gets called when I press enter
on the keyboard :/