Angular populate select with object of objects

77 views Asked by At

Give this object of objects: (filled with way more)

$scope.object = {
"activities":
{
    "1": {
        "name": "Watch a movie",
    }
    "2": {
        "name": "Chill at home",
    }
},

"people":
{
    "1": {
        "name": "with your best friend",
         }
}

How can I fill my select with all names of activities?

Right now I have

Is it possible to do this?

1

There are 1 answers

0
Walter Chapilliquen - wZVanG On BEST ANSWER

Use ng-options:

<select ng-model="currentID" 
ng-options="id as activity.name for (id, activity) in object.activities">
</select>

Demo