I'm patching values to field in reactive form using the below code :
editPat(patient: Patient) {
this.regForm.patchValue({
_id: patient._id,
firstName: patient.firstName,
lastName: patient.lastName,
disease: patient.disease,
department: patient.department,
doctor: patient.doctor
});
}
In this function department and doctor formcontrols are containing select field and value does not appear in select . The value i'm assigning to formcontrol here that is value of option..
problem how can i assign value to select through patchValue .Please help me
HTML:
<div class="form-group ">
<label for="department">Department</label>
<select class="form-control" formControlName="department">
<option *ngFor="let department of departments"
value="{{ department._id }}">{{ department.Name }}</option>
</select>
</div>
Actually i'm using this code and after saving data in db (i.e id) when i tried to patch value (for update option) other fields works but for select its does not work..