0

Hier benutze ich ngx-bootstrap für modal für das ich benutze sein erstes modales Beispiel von ngx-bootstrap website..why ich bin nicht in der Lage meine Vorlage 2 öffnen Dies ist mein CodeNgx-bootstrap Fehler als self.context.openModal.template ist keine Funktion für Modal

<button type="button" class="btn btn-primary" (click)="openModal.template()">Create template modal</button> 

<template #template> 
    <div class="modal-header"> 
     <h4 class="modal-title pull-left">Modal</h4> 
     <button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()"> 
      <span aria-hidden="true">&times;</span> 
     </button> 
    </div> 
    <div class="modal-body"> 
     This is a modal. 
    </div> 
</template> 

Module.ts

import { ModalModule } from 'ngx-bootstrap'; 
    imports: [AlertModule.forRoot(), ModalModule.forRoot()] 

Component.ts

import { BsModalService } from 'ngx-bootstrap'; 
import { BsModalRef } from 'ngx-bootstrap/'; 
    public modalRef: BsModalRef; 
constructor(private modalService: BsModalService){} 
openModal(template: TemplateRef<any>) { 
     debugger; 
     this.modalRef = this.modalService.show(template); 
    } 

Antwort

0

Sie rufen fälschlicherweise openModal Methode. Diese openModal.template() setzt voraus, dass openModal eine Objekt- oder Klasseninstanz ist, die template() Methode hat.

Korrekter Weg wäre openModal(template)

Verwandte Themen