I have a problem with angular. I am trying to call a function to generate a pdf by clicking a button in one form. PDF generation is working well because the response i got from the api is correct but in angular the modal windows doesn't appear.
That's the HTML
<div class="pb-5">
<button (click)="downloadPdf(downloadPdfTemp)" class="btn btn-link pl-0 pt-0">
<i class="fa fa-plus mr-2"></i> Genera ora il modulo precompilato </button>
</div>
<ng-template #downloadPdfTemp let-c="close" let-d="dismiss" let-modal>
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title-2">Documento generato!</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Il tuo documento è pronto per essere scaricato e firmato. Clicca sul pulsante in basso.</p>
</div>
<div class="modal-footer">
<a [href]="api + pathNamePdf" class="btn btn-primary" target="_new" (click)="modal.dismiss()">
<i class="fa fa-download pr-2"></i>Scarica ora </a>
</div>
</ng-template>
And that's the typescrypt part with the downloadPDF
downloadPdf(content): void {
this.announcements
.announcementGenerateDoc(
this._id,
this.userId,
this.announcementObj.additionalInfos
)
.pipe(takeUntil(this.destroy$))
.subscribe(genDoc => {
this.tmpGenPdf = genDoc.name;
this.announcements
.announcementGeneratePdf(this._id, this.userId)
.pipe(takeUntil(this.destroy$))
.subscribe(pathName => {
this.pathNamePdf = pathName.name;
this.modalService.open(content, { centered: true });
});
});
}
I just tried to add a delay because pdf file is generating like 1-2 second after the button has been pressed but the modal window doesn't appear.
I noticed that the modal windows appears only if i refresh the page.