angularjs - Showing values from object in select dropdown angular -


from api call receiving object looks , assigning $scope.countries:

$scope.countries = { au:"australia", be:"belgium", us:"united states" } 

in front end want add each country dropdown list, show full country names below. have taken many different approaches cannot work.

- australia - belgium - united states 

please see code below:

<select ng-options="(key, value) in countries" ng-change="getroles()"> 

try ,

var app = angular.module('plunker', []);    app.controller('mainctrl', function($scope) {  $scope.countries = {  au:"australia",  be:"belgium",  us:"united states"  }  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>  <body ng-app="plunker" ng-controller="mainctrl">   <select ng-model="country" ng-options="key value (key , value) in countries"></select>  </body>


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -