ng-repeat:在角度流星中访问键值对

时间:2016-04-26 12:41:09

标签: angularjs mongodb meteor

我想访问一个对象的键值对。我尝试了很多次更改名称值等。但是存在同样的问题。

我有一个像这样的mongo集合:

{
"_id" : "GdfaHPoT7FXW78awi",
"name" : "todo",
"highlight" : [ 
    {
        "status" : "upcoming"
    }, 
    {
        "status" : "overdue"
    }, 
    {
        "status" : "today"
    }
]

}

我的客户端js看起来像这样

            self.subscribe('featureDetails', () => [], {
            onReady: function() {
                self.helpers({ /// helpers to make it reactive
                    features: () => {
                        let settings = SaFeature.find({}).fetch();
                        //var subSettings = []
                        return {
                            settings
                        };
                    }
                })
            }
        });

和我的html一样

    <div layout="row" ng-repeat="list in dynamicSettingsCtrl.features.settings">
    <fieldset class="standard">
          <md-checkbox aria-label="Checkbox 1" ng-model="moreOptions">
                <p>{{list.name}}</p>
            </md-checkbox>
        <div layout-gt-sm="row">


            <div ng-if="moreOptions">
                <form>
                    <md-input-container class="md-block" flex-gt-sm>
                        <label>Set Limt</label>
                        <input ng-model="maxLimit">
                    </md-input-container>
                    <md-input-container class="md-block" ng-repeat="(key, value) in list.highlight" flex-gt-sm>
                        <label>{{key}}:{{value}}</label>
                        <input ng-model="upLimit">
                    </md-input-container>
           </form>
            </div>
        </div>
    </fieldset>
</div>

如果你查看我的html,我想将键值对显示为status:即将发布。但我得到的是0:{“status”:“即将来临”}。 如何获得确切的键值对? 在此先感谢!!!

1 个答案:

答案 0 :(得分:3)

试试这个。

<md-input-container class="md-block" ng-repeat="highlight in list.highlight" flex-gt-sm>
    <div ng-repeat="(key, value) in highlight">
        <label>{{key}}:{{value}}</label>
        <input ng-model="upLimit">
    </div>
</md-input-container>