I.H*_*ann 5 angular-material angular mat-table
我想在表格单元格中添加不同样式的多行。不过,Angular Material 表似乎剥离了我的 HTML 代码。我怎样才能在Gitlab中实现类似的东西,其中一行/项目内的第一行(例如“管理员”)的样式与第二行(例如电子邮件地址)的样式不同,如代码示例所示。
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef>{{header}}</mat-header-cell>
<mat-cell *matCellDef="let row">
<!-- first approach -->
<div class="firstline">{{row.firstline}}</div>
<div class="secondline">{{row.secondline}}</div>
<!-- second approach -->
<multiline-component [firstline]="row.firstline" [secondline]="row.secondline"></multiline-component>
</mat-cell>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
<div class="firstline">{{firstline}}</div> // I want to be bold
<div class="secondline">{{secondline}}</div> // I want to be just regular
Run Code Online (Sandbox Code Playgroud)
我尝试将 [innerHTML] 与 bypassSecurityTrustHtml()-Pipe 一起使用,以防止剥离失败。我还尝试使用具有 [firstline] 和 [secondline] 属性绑定的自定义组件。
When using mat-table, mat-row and mat-cell directives as tags rather than attributes on the html table, tr, td's the layout is flex, so you need to style the table accordingly.
The elements are layed-out sideways as mat-cell is "flex: row".
If you wrap the contents you want multi-line in a "div" that should do it:
<mat-cell *matCellDef="let row">
<div>
<div class="firstline">{{row.firstline}}</div>
<div class="secondline">{{row.secondline}}</div>
</div>
</mat-cell>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4493 次 |
| 最近记录: |