ngx-bootstrap How to open a modal from another component?

后端 未结 3 1400
[愿得一人]
[愿得一人] 2021-01-11 17:03

What I\'m trying to do is open a modal from another component, however I keep getting this error TypeError: Cannot create property \'validator\' on string \'test1\'

3条回答
  •  有刺的猬
    2021-01-11 17:25

    If you use same component then, 
    
    HTML #
        
    
        // for display purpose
        
          
        
    
    COMPONENT #
    import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
    import { BsModalService } from 'ngx-bootstrap/modal';
    import { ViewChild, ElementRef } from '@angular/core';
    
          bsModalRef: BsModalRef;
    constructor(private modalService: BsModalService) {}
          @ViewChild('template') elementView: ElementRef;
        openModalWithComponent() {    
            this.bsModalRef = this.modalService.show(this.elementView);
            // this.bsModalRef.content.closeBtnName = 'Close';
            // (click)="bsModalRef.hide()"
    
        }
    

提交回复
热议问题