ngx-bootstrap modal: How to get a return value from a modal?

前端 未结 9 1495
一向
一向 2020-12-13 02:23

In my Angular 4 app, let\'s assume that I\'m inside a service.

At some point, I want to ask the user for a confirmation, currently I\'m doing it with just a co

9条回答
  •  失恋的感觉
    2020-12-13 03:04

    Try with below option which is working for me. callbackOnModelWindowClose is the return value.

    @Output() callbackOnModelWindowClose: EventEmitter = new EventEmitter();
    
    const initialState = {
              isModelWindowView: true, bodyStyle: 'row', gridDataList: this.scheduleList
            };
    
    this.modalRef = this.modalService.show(YourComponent,
              Object.assign({}, this.modalConfig, { class: 'modal-dialog-centered', initialState });
    
    this.modalRef.content.callbackOnModelWindowClose.take(1).subscribe(() => {
                your code here..
              });
    

提交回复
热议问题