swati kiran swati kiran - 7 months ago 33
Javascript Question

select key/value in angularjs

Im getting json values from http service for each id.. trying to give a drop down with list of names and ids as key to store . If I have this in my html

<option ng-repeat="(key, value) in data" value="{{key}}">{{value}}</option>

this in my controller

$http.get('/api/v1/secure/admin/groups/v/users').success(function(response) {
var j=[];
var k=[];



console.log(response[0]._id)//getting 1st id
console.log(response[0].name.prefix+" "+response[0].name.first+" "+response[0].name.last)//getting name

for (var i =0; i<response.length; i++) {

j= (response[i].name.prefix+" "+response[i].name.first+" "+response[i].name.last);

console.log("list of visit manager: "+$scope.vManagerName+" id "+$scope.vManagerId);


$scope.vManagerId.push(k) : $scope.vManagerName.push(j)


but its undefined ...please help..thanks in advance


You don't need to map on controller as you are doing wrong

Try like this


<select ng-model="model" ng-options="d._id as d.name.prefix+' '+d.name.first+' '+d.name.last for d in data">