angular - 为什么用户无法编辑该引导表?

标签 angular html css bootstrap-4

我刚刚实现了这个引导表:
enter image description here

这是它的 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/

相关文章:

angular - @Angular 中的 Lodash 替换

html - CSS 选择器 :almost-empty?

html - 中下屏幕上的背景图像在 img 的水平底部制作空白

html - 创建导航栏 我在 float 时遇到问题 我的链接位于左侧,但我想要右侧

css - 文本对齐 :center centers images too

css - 跨浏览器的 px 和 em 字体大小不一致

css - ngClass 中的条件发生变化但类未更新

angular - TS2345 : Argument of type 'string | null' is not assignable to parameter of type 'string | UrlTree'

angular - 在带 Angular 选择中加载默认选项

javascript - 带有两个选择框、iframe 和 jQuery 的动态页面(不含 PHP)