Here is what seems to be bothering a lot of people (including me).
When using the ng-options
directive in AngularJS to fill in the options for a &
This is how I resolved this. I tracked the select by value and set the selected item property to the model in my JavaScript code.
Countries =
[
{
CountryId = 1, Code = 'USA', CountryName = 'United States of America'
},
{
CountryId = 2, Code = 'CAN', CountryName = 'Canada'
}
]
vm
is my controller and the Country in the controller retrieved from the service is {CountryId =1, Code = 'USA', CountryName='United States of America'}
.
When I selected another country from the select dropdown and posted my page with "Save", I got the correct country bound.