0
votes

I am building reactive form in which I have a mat-select dropdown with two button submit and load data . If user click on load data button I have to set a value to drop down I am using reactive forms patchValue() method to achieve this but the value the not reflected in option. I have created the same scenario under this link `

https://stackblitz.com/edit/angular-select-dropdown-reactive-form-yhevca?file=src%2Fapp%2Fapp.component.ts

`

could anyone please tell me how can I achieve this

2

2 Answers

2
votes

You are patching cityName: "srinagar" this value doesn't exist in the cities options list, try to use one of the options values e.g "Florida" and you will see the patched value correctly bindded

0
votes

Try adding this in your loadData()

this.registrationForm.controls["cityName"].setValue(this.City[0]);

Here I'm setting the value of 0th index of your array. You can set any value you want.