使用角度为4的行中的数据绑定模态弹出窗口

时间:2018-02-26 09:47:11

标签: angular popup ngx-bootstrap

这里我有一个小的crud角应用程序,我的问题是,如何获得表格行中显示的员工的ID,所以我可以发出删除请求,应该确认(触发,我不要& #39; t)知道当弹出模式弹出时......

这是我的员工班级

export class employee {
Id: string;
FirstName: string; 
Email: string;

 }

在我的服务中

    deleteEmployee(emp: employee) { 
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });
    return this.http.delete(url +  emp.Id);
    }

在我的组件中

   DeleteEmployee(e: employee) {

  this._usermanagementservice.deleteEmployee(this.Demoemployee).subscribe(res 
  => {
        this.LoadAllEmployees();
    });
}
   DeleteEmp() {
    this.DeleteEmployee(this.Demoemployee);
    this.LoadAllEmployees();
    this.modalRef.hide();
    }

调用ngx bootstrap模式

  openModalDelete(templateDelete: TemplateRef<any>) {
    this.modalRef = this.modalService.show(templateDelete, this.config);
  }

在我的component.html中

 <table style="width:100%" class="table table-striped" id="billing_history_table">
    <thead class="head">
        <tr>
            <th>Employee Name</th>
            <th>Position</th>
            <th>Mail</th>
            <th></th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let e of employeelist">
            <td>{{e.firstName}}</td>
            <td>{{e.positionId}}</td>
            <td>{{e.email}}</td>

            <td><a (click)="openModalDelete(templateDelete)"><span class="glyphicon glyphicon-trash"></span></a></td>
        </tr>
    </tbody>
</table>

带有确认按钮的templateDelete模板应该调用DeleteEmp函数(我猜)

    <ng-template #templateDelete>
    <div class="modal-body text-center">
    <p>Do you want to confirm?</p>
    <button type="button" class="btn btn-default" 
    (click)="confirm()">Yes</button>
    <button type="button" class="btn btn-primary" 
    (click)="decline()">No</button>
    </div>

注意到我没有api的问题,或者一般的任何错误,我的应用程序的其他部分工作得很好(比如添加新的表单,否则),弹出模式工作,打开小确认“是”按钮有效的对话框(在控制台上打印出一些消息等)我不确定,如何获得同一行员工的身份证,然后打开应该带有该ID的模式并将其传递给我删除从组件调用的函数

我为我糟糕的英语道歉,我希望有人理解我的问题:/

PS。我试过直接调用它,没有弹出窗口,从行中断开,点击glyphicon,然后找回错误......

0 个答案:

没有答案
相关问题