【发布时间】:2019-12-04 08:46:13
【问题描述】:
我使用 ng-bootstrap 创建带有 HTML 和绑定的 Popover。 ng-template 将始终在我单击按钮时重新创建,并且我的组件需要一些时间来初始化,所以我应该隐藏它。我怎么能隐藏 ng-template?
ps。我不是英语母语,如果我混淆了你,请原谅我。
我尝试使用 ng-container 但 ngbPopover 似乎只接受 ng-template
<button type="button" class="card tools-toc btn btn-outline-primary"
#popover="ngbPopover" [ngbPopover]="popLegend" [ngClass]="{'active': popover.isOpen()}"
placement="top" [autoClose]="false" popoverClass="popover-legend" (click)="toggleToc()">
<i class="fas fa-layer-group"></i>
</button>
<ng-template #popLegend>
<div>
<div class="legend-title">ชั้นข้อมูล</div>
<div >
<app-core-toc [config]="_configService[1]" [omElec]="true">
</app-core-toc>
<app-core-toc [config]="_configService[0]" [omWork]="true">
</app-core-toc>
</div>
</div>
</ng-template>
我希望在初始化时创建 app-core-toc。当我点击按钮时,我的模板只是隐藏或显示。
【问题讨论】:
-
ngIf 能解决问题吗?我不明白你的问题
-
我尝试使用但似乎 ngbPopover 只接受 ng-template 但使用它总是会破坏模板。我该怎么办?您目前使用的是什么库?您也可以在stackblitz.com 上为我创建最小代码吗?
标签: angular typescript ng-bootstrap