我是 Angular 的新手,我对带有ng-Bootstrap 的Modals有一些疑问。我已经能够打开相同组件中的模态并且它们工作正常,一个例子是这个:
关联:
<a (click)="openAbout(contentAbout)" class="nav-link">About</a>
点击事件:
openAbout(contentAbout) {
this.modalService.open(contentAbout, { centered: true, scrollable: true });
}
模态:
<ng-template #contentAbout let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title" id="modal-primary-title">About us</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body centered">
<h2>Gravity Now!</h2>
<p>It is a platform designed for Space Apps Challenge and the Challenge Gravity Map, Earth Watch category and was chosen in the Top 5 of The Most Inspiring Projects of 2014.</p>
<a href="https://2014.spaceappschallenge.org/awards/#globalawards" target="_blank">
<img id="spaceLogo" src="./assets/space_apps.png">
</a>
<br>
<img id="supernovaLogo" src="./assets/supernova-logo.png">
<p>Also, you can download our apps.</p>
<div class="row">
<div class="col">
<a href="https://play.google.com/store/apps/details?id=tk.supernova.gnow" target="_blank">
<img class="logo" src="./assets/android.png">
</a>
</div>
<div class="col">
<a href="https://www.microsoft.com/en-us/p/gravity-now/9nblgggzjlp5" target="_blank">
<img class="logoWindows" src="./assets/windows.png">
</a>
</div>
</div>
</div>
</ng-template>
它可以工作,但是,我想将此模态移动到子组件,因为我有 4 个模态并且代码看起来有些杂乱无章,但是如果我创建一个新的子组件,请将模态代码移动到子组件,然后,我像这样将它添加到父组件中:
<app-about></app-about>
什么都没有发生,因为点击没有打开任何东西。有没有人有类似的经历?你知道我应该在点击事件中改变什么吗?
我什至阅读了文档,但找不到与我的文档相关的示例:
https://ng-bootstrap.github.io/#/components/modal/examples
感谢您的任何想法。