[英]Angular 4 : add new td to table with *ngif with modulo in an *ngfor
[英]How to use *ngIf condition inside the <td> field of table using angular where *ngFor is looping?
实际上,在我的component.ts文件中,我使用了api来调用该方法,并且该方法正在返回对象数组。
当我试图在标签中使用ngIf来根据client.auditorGroup隐藏/显示列时,我的问题就开始了,因为它是true还是false(它是boolean类型),但是它没有给我访问权限:
第一个代码:
ngOnInit() {
this.http.get('http://localhost:8080/api/selections')
.subscribe((data: any[]) => {
this.clients = data;
console.log(this.clients);
this.chRef.detectChanges();
const table: any = $('table');
this.dataTable = table.DataTable();
});
}
在我的html代码中,我使用了此Edit Delete,它是h
<table class="table table-bodered">
<thead>
<tr>
<th>Mag No</th>
<th>SelectionDate</th>
<th> SelectedBy</th>
<th>PanEximNumber</th>
<th>Name</th>
<th>Address</th>
<th>PhoneNumber</th>
<th>SelectionType</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let client of clients">
<td>{{client.selectionId}}</td>
<td>{{client.selectionDate}}</td>
<td>{{client.selectedBy}}</td>
<td>{{client.panEximNumber}}</td>
<td>{{client.name}}</td>
<td>{{client.address}}</td>
<td>{{client.phoneNumber}}</td>
<td>{{client.selectionType}}</td>
<td *ngIf="{{client.auditorGroup}}==false">Edit Delete</td>
</tr>
</tbody>
</table>
使用*ngIf
时删除插值{{}}
<td *ngIf="!client.auditorGroup">Edit Delete</td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.