2 回答

TA贡献1936条经验 获得超6个赞
Update your code like this
<table class="table table-hover table-striped tborder">
<thead>
<tr>
<th scope="col">#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Address</th>
<th></th>
<th></th>
<th></th>
<!-- <th>Ph. Number</th> -->
</tr>
</thead>
<tbody>
<tr *ngFor="let cd of service.list; index as i">
<th scope="row">{{ i + 1 }}</th>
<td>{{ cd.FirstName }}</td>
<td>{{ cd.LastName }}</td>
<td>{{ cd.Address }}</td>
<!-- <td>{{ cd.PhoneNumber }}</td> -->
<td
(click)="contactInfo(cd.CTId)"
class="tfunction"
data-toggle="modal"
data-target="#infoModal"
>
<i class="far fa-eye fa-lg"></i>
</td>
<td class="tfunction" (click)="populateForm(cd)">
<i class="far fa-edit fa-lg text-info"></i>
</td>
<td class="tfunction" (click)="onDelete(cd.CTId)">
<i class="far fa-trash-alt fa-lg text-danger"></i>
</td>
</tr>
</tbody>
</table>
place your modal to bottom
<div
class="modal fade"
id="infoModal"
tabindex="-1"
role="dialog"
aria-labelledby="infoModalLabel"
aria-hidden="true"
>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="infoModalLabel">
Contact Details
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="container">
<p class="details">
<span class="detail-label">First Name:</span>
{{ currentContactInfo .FirstName }}
</p>
<p class="details">
<span class="detail-label">Last Name:</span> {{ currentContactInfo .LastName }}
</p>
<p class="details">
<span class="detail-label">Address:</span> {{ currentContactInfo .Address }}
</p>
<p class="details">
<span class="detail-label">Phone Number:</span>
{{ currentContactInfo.PhoneNumber }}
</p>
</div>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-primary btn-lg"
data-dismiss="modal"
>
Close
</button>
</div>
</div>
</div>
</div>
Finaly in your .ts do this
``
//declare a variable that contain the current contact info
currentContactInfo: any = {};
contactInfo(id){
this.service.getContactDetail(id).subscribe(res => {
this.currentContactInfo = res;
});
}
``
- 2 回答
- 0 关注
- 144 浏览
添加回答
举报