我嵌套了表格,当单击一行时,我需要在表格行下方显示数据。但是,数据显示在 ngRepeat 的末尾。
HTML:
<table class="table table-hover table-bordered table-responsive-xl">
<thead>
<th> Name </th>
<th> Place </th>
<th> Phone </th>
</thead>
<tbody>
<tr *ngFor="let data of data1" (click) ="expand()">
<td> +{{data.name}} </td>
<td> {{data.place}} </td>
<td> {{data.phone}} </td>
<td> {{data.hobbies}} </td>
<td> {{data.profession}} </td>
</tr>
<ng-container *ngIf="expandContent">
<tr *ngFor="let data of data2">
<td> {{data.datades.name}} </td>
<td> {{data.datades.hobbies}} </td>
<td> {{data.datades.profession}} </td>
</tr>
</ng-container>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
成分 :
export class AppComponent {
expandContent = true;
data1 =[{
'name' : 'john',
'place' : …Run Code Online (Sandbox Code Playgroud) 我有一个包含输入字段的表,我正在其中填充模型值,我想对这些填充的字段应用只读/禁用。当我单击添加行时,我将空行添加到表中。添加到表中的空行必须是可编辑的。我无法找到仅对已填充的表格单元格应用只读/禁用的逻辑。
超文本标记语言
<table>
<thead>
<th> Name </th>
<th> Age </th>
<th> Url </th>
<th> Gender </th>
<th> Image </th>
<th> Keywords </th>
</thead>
<tbody>
<tr *ngFor="let data of userList; let $index = index">
<td> <input class="form-control" type="text" id="userListName"[(ngModel)]="userList[$index].name"
name="userListName{{$index}}" [readonly]="userList[$index].name.length"/></td>
<td> <input class="form-control" type="text" id="userListAge" [(ngModel)]="userList[$index].age"
name="userListAge{{$index}}" readonly/></td>
<td><input class="form-control" type="text" id="userListUrl" [(ngModel)]="userList[$index].url" name="userListUrl{{$index}}" readonly/></td>
<td> <input class="form-control" type="text" id="userListGender" [(ngModel)]="userList[$index].gender"
name="userListGender{{$index}}" readonly/></td>
<td> <input class="form-control" type="text" id="userListImage" [(ngModel)]="userList[$index].image"
name="userListImage{{$index}}" readonly/>
</td>
<td> <input class="form-control" type="text" id="userListKeywords" [(ngModel)]="userList[$index].keywords"
name="userListKeywords{{$index}}" readonly/></td> …Run Code Online (Sandbox Code Playgroud)