Goal: I want to get the value of a (reactive) form control in Angular/TypeScript.
What's happening: I am able to get the values of everything except one particular field("testfield1").
Tried:
I've tried changing the name.
I've tried clearing cache and using incognito mode.
I've tried using controls[] vs .get() (as mentioned in different SO articles: How to get value of a FormControl in Angular4 ) ( formGroup.get vs formGroup.controls in reactive form - Angular )
TS:
console.log(this._pForm.controls["firstName"].value);
console.log(this._pForm.controls["lastName"].value);
console.log(this._pForm.controls["testField1"].value);
console.log(this._pForm.get("testField1").value);
HTML:
mat-form-field class="input-width">
<input matInput placeholder="TestField" id="testfield" formControlName="testField1" value="testvalue">
</mat-form-field>
I would like to be able to get the value of "testField1." It prints values for firstName and lastName, but for testField1 it just shows null. It was working yesterday so I'm not sure what is going on now.