我想提供另一个徽标,如果一个*ngIf返回真。
为此,我创建了一个ng-template,并希望将其显示在一个ng-container中。
不幸的是,我现在不能得到它。我做错了什么?
这是我的ng-template:
<ng-template *ngIf="customLogo" #customHeader>
<ng-container *myHeader>
<img src="{{customSrc}}}" alt="..." class="">
</ng-container>
</ng-template>我想在这里使用它:
<nav *navItems>
<ng-container *ngTemplateOutlet="customHeader"></ng-container>
<ng-container *ngFor="let bc of bcases">
// Some other stuff..
</ng-container>
</nav>发布于 2019-06-04 20:18:32
我刚刚发现我不能将一个ng容器嵌套在一个ng模板中。
我是这样解决的:
<ng-container *ngIf="customLogo">
<ng-container *myHeader>
<img src="{{customLogoSrc}}" alt="" class="">
</ng-container>
</ng-container> https://stackoverflow.com/questions/56443408
复制相似问题