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
Post a Comment