【发布时间】:2020-02-01 19:56:39
【问题描述】:
我正在尝试制作一个表格,它位于表格行的正下方。我知道我的表单格式不正确,但我正在尝试一次解决多个问题。我对 Angular 很陌生,我只做过一次英雄之旅。我需要构建一个 java 后端和 Angular 前端,所以请注意这一点。我想在单击编辑时显示我的一个表单,但弹出所有表单。 我无法链接 stackblitz,因为出于某种原因我确实尝试过它不允许我这样做。如果您对我想做什么有任何疑问,请告诉我。给出的第一个答案没有回答我的问题,所以请提交更多。
home.component.html
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Product</th>
<th>Category</th>
<th>FullPrice <i id ="asc-desc1"class="fas fa-angle-down" (click)="SortPrice($event)"></i></th>
<th>Saleprice <i id ="asc-desc2"class="fas fa-angle-down" (click)="SortSale($event)"></i> </th>
<th>Supplier</th>
<th>Discount<i id ="asc-desc3"class="fas fa-angle-down" (click)="SortDiscount($event)"></i></th>
<th>Edit</th>
</tr>
</thead>
<tbody *ngFor="let home of home | paginate:{itemsPerPage:20,currentPage: p}" >
<tr *ngIf="!editMode">
<td >{{home.id}}</td>
<td>{{home.productName}}</td>
<td>{{home.category.categoryName}}</td>
<td>{{home.fullPrice}}</td>
<td>{{home.salePrice}}</td>
<td>{{home.supplier.supplierName}}</td>
<td>{{home.discount }}</td>
<td class="text-right" id="tableDataBtns">
<div class="btn-group" role="group">
<button (click)="editMode=true" type="button" class="btn btn-secondary"><i class="far fa-edit"></i></button>
<button type="button" class="btn btn-danger"><i class="far fa-trash-alt"></i></button>
</div>
</td>
</tr>
<tr *ngIf="editMode">
<td><input placeholder="{{home.id}}"/></td>
<td><input placeholder="{{home.productName}}"/></td>
<td><input placeholder="{{home.category.categoryName}}"/></td>
<td><input placeholder="{{home.fullPrice}}"/></td>
<td><input placeholder="{{home.salePrice}}"/></td>
<td><input placeholder="{{home.supplier.supplierName}}"/></td>
<td><input placeholder="{{home.discount }}"/></td>
<td class="text-right" id="tableDataBtns">
<div class="btn-group" role="group">
<button (click)="editMode=true" type="button" class="btn btn-secondary"><i class="far fa-edit"></i></button>
<button type="button" class="btn btn-danger"><i class="far fa-trash-alt"></i></button>
</div>
</td>
</tr>
</tbody>
</table>
<pagination-controls class="myPagination" (pageChange)="p= $event"></pagination-controls>
</div>
我想要什么我只希望能够展示和编辑一个产品 我不处于编辑模式时的外观 当我处于编辑模式时它的外观所有表单都显示我只想要一个
【问题讨论】:
-
嗯,这应该可以工作(单行),所以您能否提供一个minimal reproducible example 来重现您的问题?
-
您可以在stackblitz.com上进行操作
-
我很抱歉,我在这样做时遇到了问题,由于某种原因它不允许我使用我的存储库。
-
你可以通过添加没有显示CSS的类来做到这一点使用ngClass
标签: angular typescript angular-ui-bootstrap