0

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 ?

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, it is list[0], I renamed it. Try it. I sent you sample code too. Please click the below URL w3schools.com/code/tryit.asp?filename=FRC5CNQZOGMS
1

In view try this

ng-options="val for val in selectedval"

1 Comment

Worked Thanks. Showing in the list , but when selecting it , breaking down to character .
0
$scope.list:[{"$id": "1",
"Groups": [
    "xyz",
    "abc",
    "ugh",
    "ccd"
]}]
$scope.list=[] // replace ":" by "="

1 Comment

Ok sorry my mistake it's actually = only . I am editing the question . Still not coming.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.