Reputation: 1121
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 `
`
could anyone please tell me how can I achieve this
Upvotes: 0
Views: 5296
Reputation: 21
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.
Upvotes: 0
Reputation: 532
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
Upvotes: 2