Какая-то конкретная причина, по которой у вас был горизонтальный стол? это просто сделало HTML немного странным. Однако следующее решение даст вам то, что вы хотели ... функция возвращает true / false, которая переключает видимость через *ngIf
.
релевантный TS:
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
name = 'Angular';
public ColumnNames: string[] = ['Legal Class Name', 'Last Edited', 'Legal Class ID'];
data: any[] = [
{ className: 'class A', edited: 'true', id: '11101' }, { className: 'class B', edited: 'false', id: '11101' },
{ className: 'class C', edited: 'true', id: '11101' }, { className: 'class C', edited: 'true', id: '11101' },
{ className: 'class E', edited: 'true', id: '11101' }, { className: 'class D', edited: 'true', id: '11101' },
{ className: 'class G', edited: 'true', id: '11101' }, { className: 'class E', edited: 'true', id: '11101' },
{ className: 'class I', edited: 'true', id: '11101' }, { className: 'class F', edited: 'true', id: '11101' },
{ className: 'class K', edited: 'true', id: '11101' }, { className: 'class G', edited: 'true', id: '11101' },
]
constructor() { }
checkVisibility() {
let columnCheck: boolean = true;
for (var i = 0; i < this.data.length; i++) {
if (this.data[i].edited == 'false') {
return false;
}
}
return columnCheck;
}
}
соответствующий HTML:
<h3>
Vertical Table
</h3>
<table class="fundClassesTable table-striped" border="1">
<thead>
<th class="tableItem bold">{{ColumnNames[0]}}</th>
<th class="tableItem bold">{{ColumnNames[1]}}</th>
<th class="tableItem bold" *ngIf='checkVisibility()'>{{ColumnNames[2]}}</th>
</thead>
<tbody>
<tr *ngFor="let f of data">
<td class="tableItem">{{f.className}}</td>
<td class="tableItem">{{f.edited}}</td>
<td class="tableItem" *ngIf='checkVisibility()'>{{f.id}}</td>
</tr>
</tbody>
</table>
<hr/>
<h3>
Horizontal Table
</h3>
<table class="fundClassesTable table-striped" border="1">
<tbody>
<tr>
<th class="tableItem bold">{{ColumnNames[0]}}</th>
<ng-container *ngFor="let f2 of data">
<td class="tableItem bold">{{f2.className}}</td>
</ng-container>
</tr>
<tr>
<th class="tableItem bold">{{ColumnNames[1]}}</th>
<ng-container *ngFor="let f3 of data">
<td class="tableItem bold">{{f3.edited}}</td>
</ng-container>
</tr>
<tr *ngIf='checkVisibility()'>
<th class="tableItem bold">{{ColumnNames[2]}}</th>
<ng-container *ngFor="let f4 of data">
<td class="tableItem bold">{{f4.id}}</td>
</ng-container>
</tr>
</tbody>
</table>
полный рабочий stackblitz здесь
person
Akber Iqbal
schedule
17.06.2019
*ngIf
, передайте ей индекс строки ... TS: проверьте предыдущий индекс на ваше условие и передайте истину / ложь; - person Akber Iqbal   schedule 14.06.2019Last Edited
т.е.AuditSummary
верно? Нравится? - person Munim Munna   schedule 16.06.2019