How to pass parameteres to modal?

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

    Here's how you can pass data to your HTML Template in Angular2

    import {Component} from '@angular/core';
    import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
    
    @Component({
    selector: 'add-customer-modal',
    template: `
    
    `})
    
    export class AddCustomerModal {
       MESSAGE_DATA : any;
       constructor(private modalService: NgbModal) {}
    
       open(content) {
          this.MESSAGE_DATA = "PASS DATA TO ANGULAR2 MODAL"
          this.modalService.open(content, { size: 'lg' }).result.then((result) => {
             console.log(result);
          }, (reason) => {
          console.log(reason);
        });
     }
    }
    

    check how MESSAGE_DATA is used inside HTML Template.

提交回复
热议问题