Here is the HTML code I am working with:
<select ng-options="value.name for (key, value) in countries track by key" ng-model="selected" >
</select>
This is the specific object I am trying to manipulate:
$scope.countries = {
"AFG":{"name":"Afghanistan"},
"ALB":{"name":"Albania"}
};
$scope.countriesKeys = Object.keys($scope.countries);
$scope.selected = ????;
The main issue I am encountering is figuring out how to get the ng-model
selected to function correctly due to the structure of the object being challenging. Unfortunately, I am unable to modify the object.
Ultimately, my goal is to have the <select>
default to display "ALB":{"name":"Albania"}
as the initial option and then have it update dynamically when different options are selected, changing the $scope.selected
accordingly.