[英]Passing data from ngx-bootstrap Modal to Component
I have an array drivers in my component.我的组件中有一个阵列驱动程序。 I'm showing a ngx-bootstrap modal with a value fullname from the drivers array when i click a button in the component.当我单击组件中的按钮时,我正在显示一个 ngx-bootstrap 模式,其值来自驱动程序数组的全名。 Now i want to get the data back from the modal like which name is selected.现在我想从模式中取回数据,比如选择了哪个名称。 How to do that?怎么做?
<button type="button" class="btn btn-success btn-round" (click)="staticModal.show()">{{'Assign Driver' | translate}}
</button>`
<div class="modal fade" bsModal #staticModal="bs-modal"
tabindex="-1" role="dialog" aria-labelledby="dialog-static-name">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 id="dialog-static-name" class="modal-title pull-left">Select Drivers</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="staticModal.hide()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div *ngFor= "let dri of drivers">
<input type="radio" id="customRadio1" name="customRadio">
<label>{{dri.fullname}}</label>
</div>
<div class = "modal-footer">
<button type="button" class="btn btn-primary" (click)="staticModal.hide()" >Select Driver</button>
<button type="button" class="btn btn-default" (click)="staticModal.hide()">Cancel</button>
</div>
</div>
</div>
</div>
</div>
I want to get value of the selected radio button in the component.我想获取组件中选定单选按钮的值。 And when the modal is closed i want to perform the method placeorder() which i already How to do that?当模式关闭时,我想执行我已经执行的方法 placeorder() 如何做到这一点?
open() {
const modalRef = this.modalService.open(NgbdModalContent);
modalRef.componentInstance.data = //'your data want to sent in model';
modalRef.result.then((response) => {
console.log(response);
});
In Model component在 Model 组件中
@input() data : any;
closel() {
let data = [1,2,3,4,5,6];
this.activeModal.close(data);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.