Current Angular version - 1.2.28 (Legacy, pending upgrade)
I'm currently facing an issue with setting the default selected value for a select element based on the model value.
In my Controller, I have this code snippet;
$scope.customer.country = 'GB';
And in my view, I have a select element like this;
<select
ng-model="customer.country"
ng-options="country as country.name for country in countries track by country.alpha2">
</select>
My expectation was that if there's an object in the 'countries' array with the alpha2 value of 'GB', it would be automatically selected upon rendering.
However, the actual behavior is that the default option appears empty.
Can you help me understand how to set the default selected value using the model (ng-model
) value?