gpt4 book ai didi

angularjs - 如何显示动态到html的键名

转载 作者:可可西里 更新时间:2023-11-01 09:58:52 27 4
gpt4 key购买 nike

这里我有一个 mongo 集合,比如

"dashboard" : {
"todo" : {
"_id" : "GdfaHPoT7FXW78awi",
"_maxCount" : "1",
"_title" : "todo",

}
"task" : {
"_id" : "GdfaHPoT7FXW78awi",
"_maxCount" : "1",
"_title" : "task",

}
}

这里的 task 和 todo 是动态字段名称,我在 ng-repeat 中循环了仪表板。现在我想知道如何在仪表板内显示详细信息。

最佳答案

通过它

var jimApp = angular.module("mainApp",  []);

jimApp.controller('mainCtrl', function($scope){
$scope.dashboard = {
"todo" : {
"_id" : "GdfaHPoT7FXW78awi",
"_maxCount" : "1",
"_title" : "todo"
},
"task" : {
"_id" : "GdfaHPoT7FXW78awi",
"_maxCount" : "1",
"_title" : "task",
}
};
});
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="mainApp" ng-controller="mainCtrl">
<div class="col-xs-4" ng-repeat="(itemName, item) in dashboard">
<div class="panel panel-info">
<div class="panel-head bg-info">{{itemName}}</div>
<div class="panel-body">{{item._title}}&nbsp;{{item._maxCount}}</div>
</div>
</div>
</div>

关于angularjs - 如何显示动态到html的键名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36980207/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com