Home > database >  How to set selections on an Angular multiselect with reactive forms?
How to set selections on an Angular multiselect with reactive forms?

Time:01-17

The best way to explain the issue... in this StackBlitz, I'd like to set the selection to 'Florida' and see that option selected.

https://stackblitz.com/edit/angular-multi-select-dropdown-reactive-forms-jb7x2h?file=src/app/app.component.html

I am able to set and get the values just fine from the FormControl, but visually the select does not show the options properly selected.

CodePudding user response:

I wrote something for you here(forked your blitz). This should work for you.

https://stackblitz.com/edit/angular-multi-select-dropdown-reactive-forms-tgwe3n?file=src/app/app.component.ts

Let me know if you need another thing

CodePudding user response:

Only you have to access the attribute you want to update, in this case the one on line 43 on app.component.html

{{ registrationForm?.getRawValue().cityName }}
  • Related