0

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)

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

what do I put in my ng-options?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.