How can i have a default value according to what i already selected before. Like if i edit something and it has a dropdown, i can see the default value that i have submitted before so it won't confused the users. For example, in my code if i click the edit button it would redirect me to the page and would start the "patchValues()" function below and it would able to select from the lists of suppliers. What i want is that if i click the edit button, i can see a default value in the select option
TS
patchValues() {
let suppliers = this.myForm.get('suppliers') as FormArray;
this.material.suppliers.forEach(supplier => {
suppliers.push(this.fb.group({
supplier_id: supplier.name,
}))
})
}
HTML
<tr *ngFor="let row of myForm.controls.suppliers.controls; let i = index" [formGroupName]="i">
<td>
<select formControlName="supplier_id" class="col-md-12" >
<option *ngFor="let supplier of suppliers" [value]="supplier.id">
{{supplier.name}}
</option>
</select>
</td>
</tr>