【发布时间】:2018-09-14 22:27:38
【问题描述】:
我是 Angular 的新手,所以请理解我 :)
我有一个用户列表,显示如下:
这是我的 HTML:
编辑 - 添加 CRUD 按钮:
<!--Add new button-->
<button type="button" (click)="AddModal.show()">
</button>
<button type="button" (click)="EditModal.show()">
</button>
<button type="button" (click)="DeleteModal.show()">
</button>
</div>
<!--Data Tableq which displays users info-->
<div class="dash-table-container">
<table class="table table-hover">
<thead>
<tr>
<th>
Name
<i class="fas fa-sort-amount-down sorting-icon"></i>
<i class="fas fa-sort-amount-up sorting-icon" style="display: none;"></i>
<i class="fas fa-sort sorting-icon" style="display: none;"></i>
</th>
<th>
Position
<i class="fas fa-sort-amount-down sorting-icon" style="display: none;"></i>
<i class="fas fa-sort-amount-up sorting-icon" style="display: none;"></i>
<i class="fas fa-sort sorting-icon-default"></i>
</th>
<th>
Office
<i class="fas fa-sort-amount-down sorting-icon" style="display: none;"></i>
<i class="fas fa-sort-amount-up sorting-icon" style="display: none;"></i>
<i class="fas fa-sort sorting-icon-default"></i>
</th>
<th>
Age
<i class="fas fa-sort-amount-down sorting-icon" style="display: none;"></i>
<i class="fas fa-sort-amount-up sorting-icon" style="display: none;"></i>
<i class="fas fa-sort sorting-icon-default"></i>
</th>
<th>
Salary
<i class="fas fa-sort-amount-down sorting-icon" style="display: none;"></i>
<i class="fas fa-sort-amount-up sorting-icon" style="display: none;"></i>
<i class="fas fa-sort sorting-icon-default"></i>
</th>
</thead>
<!--<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>-->
<tbody>
<tr *ngFor="let u of users; let i=index;">
<td>{{u.Name}}</td>
<td>{{u.Position}}</td>
<td>{{u.Office}}</td>
<td>{{u.Age}}</td>
<td>{{u.StartDate}}</td>
<td>{{u.Salary}}</td>
</tr>
</tbody>
</table>
</div>
<app-product-new #AddModal></app-group-new>
<app-product-edit #EditModal></app-group-edit>
<product-dialog #DeleteModal></touch-dialog>
我想知道如何使用角度从该表中选择一行? 我需要它,因为我想将该选定行的数据发送到模态进行编辑..
编辑:
所以基本上,当我选择一行并单击编辑模式时,我想知道选择了哪一行,以便我可以使用该信息填充模式的数据并保存/编辑它..
谢谢
谢谢各位! 干杯
【问题讨论】:
-
将点击处理程序添加到您的
<tr *ngFor="let u of users; let i=index;" (click)="RowSelected(u)">并在此点击处理程序上打开模式以修改数据
标签: angular twitter-bootstrap data-binding datatables selection