小编Luk*_*uke的帖子

使用 Angular 保留表的 <td> 中的前导空格

我正在使用 Angular 和 Metronic 的项目(https://preview.keenthemes.com/metronic/demo1/index.html),我需要在表格中放入一些信息,这些信息是以空格开头的单词,我需要打印这些空白,但表格对文字进行了修剪。

这是我的代码:

    <table style="width:100%" class="table table-striped table-hover table-sm" [mfData]="list" #mf="mfDataTable">
   <thead>
    <tr class="bg-primary text-light">
     <th style="width: 10%"><mfDefaultSorter by="code">Code<i class="fa fa-sort"></i></mfDefaultSorter></th>
     <th style="width: 30%"><mfDefaultSorter by="desc">Desc<i class="fa fa-sort"></i></mfDefaultSorter></th>
    </tr>
   </thead>
   <tbody>
    <tr *ngFor="let item of mf.data | filterBy:['code', 'desc']:filterText; let i = index">
     <td>{{ item.code }}</td>
     <td>{{ item.desc }}</td>
    </tr>
   </tbody>
  </table>
Run Code Online (Sandbox Code Playgroud)

结果或多或少是这样的:

在此输入图像描述

html pipe angular

3
推荐指数
1
解决办法
1701
查看次数

标签 统计

angular ×1

html ×1

pipe ×1