【发布时间】:2019-03-30 17:14:10
【问题描述】:
在表头中,我有动态列和搜索排序功能。但对于特定列,我需要禁用排序功能。 在表中
<thead>
<tr class="table-head">
<th *ngFor="let colName of reportColHeader; let i = index">
{{colName}}
<i [class]="sortIcons[colName]" (click)="toggleSort(colName, i)"></i>
</th>
</tr>
</thead>
在 constructor 我将值作为数组传递。不是来自服务器,它只是静态的
this.reportColHeader = ['ID', 'LABEL 1', 'LABEL 2', 'More'];
所以结果将如下所示
<tr>
<th>ID <i></i></th>
<th>LABEL 1 <i></i></th>
<th>LABEL 2 <i></i></th>
<th>More <i></i></th>
</tr>
在这里我想禁用特定列的 (排序功能)。
不仅是最后一列或第 n 列。
我的假设是,可能还有一个像
this.reportColHeaderOptions = ['true', 'true', 'false', 'false'];
通过这个值可以显示或隐藏<i></i>
那么我怎样才能在ngFor 中传递这个。
注意:这里我不能使用索引,因为索引会改变。
但我可以按照相同的顺序关注 this.reportColHeader 和 this.reportColHeaderOpions。
【问题讨论】:
-
您也可以作为对象数组传递而不是 2 个数组,对吗?像 [{label: 'ID', isSortDisabled: true}, {label: 'LABEL 1', isSortDisabled: true}] 这样的东西?
标签: javascript html angular typescript ngfor