首页 > 解决方案 > Angular如何在没有usign按钮的情况下显示模态

问题描述

我正在使用 ng-boostrap 并且我遇到了一个问题,我有一个从 API 获得的对象数组:

  quaPacks: QualifiedSignaturePackDetailsResponse[] = [];

  ngOnInit(): void {
    this.notificationsService.getSignaturesPackNotification().subscribe({
      next: value =>{
        this.quaPacks=value
      }
    })
  }

  openModalTemplate(template: TemplateRef<any>) {
    console.log(this.quaPacks+ "smth")
      this.modalRef = this.modalService.show(template);
  }

  checkIfNull() : boolean {
    if(this.quaPacks.length != 0) {
      return true
    }
  }

HTML:

<div *ngIf="checkIfNull()">
<ng-template #template>
  <ng-container [ngModel]="openModalTemplate(template)">

对于非空列表,模式未显示。我看到了很多使用父组件的解决方案,但我想单独做一个。谢谢你的帮助。

标签: angulartypescriptbootstrap-4bootstrap-modal

解决方案


推荐阅读