【发布时间】:2020-05-26 11:32:30
【问题描述】:
嗨,我已经使用显示属性创建了一个表,现在我有一个数组,我想遍历该数组并 pring 列和行的值,这是我的代码:- html:=
<div id='table'>
<!-- table head -->
<div id="thead">
<div class="table-row">
<div class="table-cell">head 1</div>
<div class="table-cell">head 2</div>
</div>
</div>
<!-- table body -->
<div id="tbody">
<div class="table-row">
<div class="table-cell">cell 1.1</div>
<div class="table-cell">cell 1.2</div>
</div>
<div class="table-row">
<div class="table-cell">cell 2.1</div>
<div class="table-cell">cell 2.1</div>
</div>
</div>
<!-- table foot -->
<div id="tfoot">
<div class="table-row">
<div class="table-cell">foot 1</div>
<div class="table-cell">foot 2</div>
</div>
</div>
<!-- table end -->
</div>
css:
div {
padding: 5px;
}
#table {
margin: 0 auto;
display: table;
border: 1px solid green;
}
.table-row {
display: table-row;
}
.table-cell {
width: 150px;
text-align: center;
display: table-cell;
border: 1px solid black;
}
#thead {
display: table-header-group;
color: white;
background-color: red;
}
#tbody {
display: table-row-group;
background-color: yellow;
}
#tfoot {
display: table-footer-group;
color: white;
background-color: blue;
}
ts 文件 :=
auditViews : any = [
{
"id" : "log1",
"name" : "Audit log 1",
"description" : "Descrition of audit log 1",
"status" : "active"
},
{
"id" : "log2",
"name" : "Audit log 2",
"description" : "Descrition of audit log 2",
"status" : "active"
},
{
"id" : "log3",
"name" : "Audit log 3",
"description" : "Descrition of audit log 3",
"status" : "active"
}];
这是静态的,不知何故,我需要列标题是 id、名称、描述和状态,以及下面的值。
【问题讨论】:
标签: angular html-table multiple-columns ngfor ng-bind