Reputation: 393
I am getting this json data from an api:
$scope.industry = [];
$http.get('/industrygroup?languageid=1')
.then(function (result) {
$scope.industry = result.data;
});
the json data is $scope.industry
and I use ng-option to get a values for my dropdown menu:
ng-options="p.Name for p in industry[0].Occupations"
and that works fine, I am just looking to change this to use Name instead of Occupation. Here is my JSON below to show you:
{
"Language":{
"Id":1,
"Name":"English"
},
"Occupations":[
],
"Id":2,
"Name":"Food and Beverage"
}
I am looking to get the Name "Food and Beverage" in my dropdown. This was example of 1 row that was returned from my api, so I am looking to get all Names (Not Language Name)
Upvotes: 0
Views: 66
Reputation: 5848
You need to get all the names from the result.data. Something like this using underscore:
var names = _.uniq(_.pluck(result.data, 'Name')));
$scope.names = names;
This may also be what you need:
p.Name for p in industry
Upvotes: 1