【发布时间】:2017-01-26 22:42:40
【问题描述】:
我有这个来自 *ngFor 的 sn-p,所以它被填充了很多次。每个配置文件都有一个唯一的 ID,当我点击此按钮时,我想将其删除:
<a data-toggle="modal" data-target="#deleteProfile" (click)="deleteProfile.open()" role="button" style="color:red;"><i class="fa fa-trash-o" aria-hidden="true"></i> Delete</a>
html 模态:
<modal #deleteProfile>
<modal-header [show-close]="true">
<h4 class="modal-title">Delete Profile</h4>
</modal-header>
<modal-body>
<div class="text-center">
Are you sure you want to delete this profile?
</div>
</modal-body>
<modal-footer>
<div class="control-group confirm-buttons">
<div class="row text-center">
<div class="col-md-6">
<button type="button" class="btn btn-cancel" data-dismiss="modal" (click)="closeDeleteProfile()">No</button>
</div>
<div class="col-md-6">
<button type="button" class="btn btn-confirm" (click)="deleteProfile()">Yes</button>
</div>
</div>
<div class="col-md-12 text-center">
<small>This is the footer</small>
</div>
</div>
</modal-footer>
</modal>
当点击“是”按钮时调用:
deleteProfile(id: string) {
this.modalDeleteProfile.dismiss();
this.profileService.delete(id)
.subscribe(
// data => console.log(data),
// error => console.log(error)
);
this.router.navigateByUrl('/dashboard');
}
我如何将 id 传递给模态,以便上面的代码获取 id 以删除配置文件?
这是我正在使用的模式:https://github.com/dougludlow/ng2-bs3-modal
【问题讨论】:
-
我不知道这是否可能。使用了相同的模态。我只是立即使用了一种额外的方法,它只是几行。所以我没有费心去尝试实现你想要实现的目标。将关注这个问题:)
-
@AJT_82 你能举个例子吗?
-
使用“额外的方法”?
-
是的,我找不到解决方案...
-
检查答案:)
标签: angular ng2-bootstrap