How to use code to open a modal in Angular 2?

前端 未结 14 3018
天涯浪人
天涯浪人 2020-12-05 04:34

Usually we use data-target=\"#myModal\" in the

14条回答
  •  天命终不由人
    2020-12-05 04:58

    @ng-bootstrap/ng-bootstrap npm I m using for this as in the project bootstrap is used, for material, we used dialog

    HTML Code

      Open Abc Modal
     
    

    Modal template

    
       
      
    
    

    Ts File

    import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';
    
    constructor(
        private modalService: NgbModal
      ) { }
    
      openModal(modalContent){
         this.modalService.open(modalContent, { centered: true});
       }
    

提交回复
热议问题