这是它的 html 定义:
<div class="card card">
<div class="header">
<div class="typo-line">
<h4>Suivi des approbations</h4>
</div>
<!-- <h4 class="title">Table on Plain Background</h4> -->
<!-- <p class="category">Here is a subtitle for this table</p> -->
</div>
<div class="content table-responsive table-full-width">
<table class="table table-hover">
<thead>
<tr>
<th *ngFor="let cell of tableData2.headerRow">{{ cell }}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let row of tableData2.dataRows">
<td *ngFor="let cell of row">{{ cell }}</td>
</tr>
</tbody>
</table>
</div>
</div>
这是其相关的 typescript 代码:
ngOnInit(){
this.tableData2 = {
headerRow: [ 'Version', 'Approbateur(nom+fonction)', 'Principales remarques', 'Date d\'approbation'],
dataRows: [
['', '', '', ''],
['', '', '', ''],
['', '', '', ''],
['', '', '', ''],
['', '', '', ''],
['', '', '', ''],
['', '', '', ''],
]
};
这些行不可编辑。这是我的问题:
1/为什么用户端无法编辑行?
2/我怎样才能使它们可编辑?我必须使用表格吗?
谢谢你!
最佳答案
默认情况下,除了 input 标签之外,您无法编辑 html 中的元素。
但是您可以使用属性 contenteditable。这将使元素可编辑。
所以你可以像这样使用,
<tr contenteditable='true'>
<th *ngFor="let cell of tableData2.headerRow">{{ cell }}</th>
</tr>
这将使整行变得可编辑。
关于angular - 为什么用户无法编辑该引导表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56166156/