I am getting a value from PHP server to angular 6 through HttpClient, and this value is sent to a formControlInput to be set as a default value:
<mat-form-field color="warn">
<input matInput formControlName="unit_type"
placeholder="Unit type" value="{{unit_type}}">
</mat-form-field>
I am saving the same value into a variable, to compare it to the value of the input so I can detect a change, to know whether I activate the update button or not:
this.unit_type = data['unit_info'][0]['unit_type'];
Consoling this variable is showing properly, and the value is displayed inside the input.
Now when I get the value of it again like the following:
unit_type_upd = this.formGroup.controls['unit_type'].value;
console.log(unit_type_upd);
It shows me empty value, but when I change it, it will detect the change, and make the comparing process.
Why unit_type_upd is not getting the value displayed inside the input on component load ?