Search code examples
arraysangularjsjsonng-options

Show json array list in drop down angular


I am new in AngularJS and trying to show data in drop down list and facing few errors. Here is my JSON data:

$scope.list=[
{
    "$id": "1",
    "Groups": [
        "xyz",
        "abc",
        "ugh",
        "ccd"
    ]
}
]

I am trying to show list of names of Groups mentioned in the json.

In controller :-

$scope.selectedval = $scope.list[0].Groups;
console.log($scope.selectedval);

In View I am doing this :-

ng-options="item.Groups for item in list"

By doing this I am getting all the datas in single option. How to separate datas on each list by ng-option ?


Solution

  • `ng-options="item for item in list[0].Groups"