我需要将tappable
指令添加到ion-card
自定义组件内的组件.我用的@Input() myInputBool
是:
<ng-container *ngIf="myInputBool">
<ion-card tappable>
<ng-container render="myContent"></ng-container>
</ion-card>
</ng-container>
<ng-container *ngIf="!myInputBool">
<ion-card tappable>
<ng-container render="myContent"></ng-container>
</ion-card>
</ng-container>
<ng-container #myContent>
This is my content
</ng-container>
Run Code Online (Sandbox Code Playgroud)
当然它不起作用,因为没有"渲染"选项.到目前为止,我的解决方法是在ng-container中添加一个不存在的变量
<ng-container *ngIf="thisVariableDoesNotExist else myContent"> </ng-container>
Run Code Online (Sandbox Code Playgroud)
但它感觉很糟糕和黑客.有更好的方法吗?
yur*_*zui 13
我会用ngTemplateOutlet
而不是render
选项:
<ng-container *ngTemplateOutlet="myContent"></ng-container>
Run Code Online (Sandbox Code Playgroud)
也可以看看
归档时间: |
|
查看次数: |
4000 次 |
最近记录: |