How to pass parameteres to modal?

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

    I would suggest you look at the Child Modal example here ng2-bootstrap documentation for modals. Just add public variables to the parent component and use them in your modal using standard binding techniques.

    So in the example add this to the template like so:

          
    

    and change the component like this:

    export class DemoModalChildComponent {
      @ViewChild('childModal') public childModal:ModalDirective;
      parentMessage = 'I am a child modal, opened from parent component!'; //Add this
    

    Now you that you are passing in data from the parent component you can pass data to the parent component by following the standard patterns.

提交回复
热议问题