How to pass parameteres to modal?

前端 未结 6 2021
既然无缘
既然无缘 2021-02-07 10:29

That\'s the way I use the ng2-bootstrap modal:

import {Component} from \'@angular/core\';
import {NgbModal} from \'@ng-bootstrap/ng-bootstrap\';

@Component({
           


        
6条回答
  •  花落未央
    2021-02-07 10:41

    To pass parameters/data to the modal, my guess would be to use the componentInstance:

    open(content) {
        const modal: NgbModalRef = this.modalService.open(content, { size: 'lg' });
    
        (model.componentInstance).data = 'hi';
    
        modal.result.then((result) => {
          console.log(result);
        }, (reason) => {
          console.log(reason);
        });
    }
    

    This assumes that the componentInstance is of type MyComponent and that it has a public property data

提交回复
热议问题