【问题标题】:Angular populate select with object of objects角度填充选择与对象的对象
【发布时间】:2015-06-09 07:34:49
【问题描述】:

给这个对象的对象:(填充方式更多)

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

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

如何在我的选择中填写所有活动名称?

我现在有

可以这样做吗?

【问题讨论】:

  • ng-options="activity.name for (key , activity) in object.activities"
  • 非常感谢它有效

标签: json angularjs object


【解决方案1】:

使用ng-options:

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

Demo

【讨论】:

    猜你喜欢
    • 2019-02-16
    • 2022-10-01
    • 2021-05-26
    • 1970-01-01
    • 1970-01-01
    • 2020-05-13
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多