How to pass parameteres to modal?

前端 未结 6 2007
既然无缘
既然无缘 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:58

    In Angular 8 for ng-bootstrap try this

    Complete tutorial here

      openModal() {
        const modalRef = this.modalService.open(MyBootstrapModalComponent,
          {
            scrollable: true,
            windowClass: 'myCustomModalClass',
            // keyboard: false,
            // backdrop: 'static'
          });
    
        let data = {
          prop1: 'Some Data',
          prop2: 'From Parent Component',
          prop3: 'This Can be anything'
        }
    
        modalRef.componentInstance.fromParent = data;
        modalRef.result.then((result) => {
          console.log(result);
        }, (reason) => {
        });
      }
    

提交回复
热议问题