Q:

ng-options with an array of key-pair objects

I have the following data that I got from a third-party:
countries: [
    {"US":"United States"},
    {"CA":"Canada"},
    {"AF":"Afghanistan"},
    {"AL":"Albania"},
    {"DZ":"Algeria"},
    {"DS":"American Samoa"},
    .....
];

The way the data is organized is not how I would have done it, but now I need fit all of this in a select with ng-options so that both the value and the option displayed is the full name of the country
I have tried ng-options="code as name for (code, name) in countries" but I get an Object as my select value.

A:

Working plunkr here: http://plnkr.co/edit/nbWHz8g4Gn0vGuSHM5o0?p=preview
Though as Nicolas pointed out, it's probably better to transform the data?
HTML:
<!DOCTYPE html>
<html ng-app="app">

  <head>
    <script data-require="angular.js@1.2.14" data-semver="1.2.14" src="http://code.angularjs.org/1.2.14/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body ng-controller="AppCtrl">

    <select id="countries" name="countries" ng-model="selectedCountry" 
            ng-options="getKey(country) as country[getKey(country)] for country in countries"></select>

    Selected country: {{selectedCountry}}
  </body>

</html>

JS:
// Code goes here

angular.module('app',[]).controller("AppCtrl", ["$scope", function($scope) {
    $scope.countries = [
    {"US":"United States"},
    {"CA":"Canada"},
    {"AF":"Afghanistan"},
    {"AL":"Albania"},
    {"DZ":"Algeria"},
    {"DS":"American Samoa"}
];

  $scope.getKey = function(country) {
    return Object.keys(country)[0];
  }
  }]);

