I am making a reactive form which is filled with default values from my DB. So the user is free to modify some data and then send back the form. But if he chooses to not change some fields, I want to be able to get the default values when the form is sent. But I get an undefined error when I try to display the values of such fields.
I tried putting the default value directly in the formControl as it is created, display the value in a [value] attribute in the template.
I can't show you exactly what I am working on, as it's again my company's policy, but here's a pseudocode
form_control: new FormControl({ value: myValue, disabled: false }, [Validators.required]);
in template:
<input matInput placeholder="myPlaceHolder" formControlName="form_control" id="form">
I expect to see in my input my default value, and to be able to get this value even if I have not touched that field. Nothing shows in the input, and I get an undefined message when I try to display the value of the input in the console.
Thank you for helping me!
<form *ngIf="myForm" [formGroup]="myForm">....</form>