私はこのスニペットを* ngForから取得していますので、何回も入力されています。すべてのプロファイルは、一意のIDを持っていると私は、このボタンをpreesときにそれを削除する:ng2-bs3-modalにデータを渡すには?
<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
これが可能かどうかはわかりません。同じモーダルを使用しました。私はちょうどすぐに余分な方法を使用しました、それはちょうど数行でした。だから私はあなたが達成しようとしているものを達成しようとすることを気にしなかった。この質問に続きます:) – Alex
@ AJT_82あなたは例を挙げることができますか? –
の "余分な方法?" – Alex