【发布时间】:2020-04-13 03:18:42
【问题描述】:
我正在尝试在应用程序的 2 个不同位置使用 component,但我想更改 template 并保留 功能。
- 在一种情况下,我想将
component用作button。 - 在另一种情况下,我想将
component用作list item。
一切都是一样的只是 template 更改,我想知道是否有任何方法可以通过扩展 component 或更清洁的东西而不使用内部 if 来做到这一点。
一些代码:
<ng-container [ngSwitch]="status">
<button *ngSwitchCase="'none'" (click)="action()">
<ion-icon name="md-white-users"></ion-icon>
Ask to connect
</button>
<button *ngSwitchCase="'requestSent'" class="connected">
<ion-icon name="md-white-users"></ion-icon>
Request Sent
</button>
<button *ngSwitchCase="'connected'" class="connected">
<ion-icon name="md-white-users"></ion-icon>
Connected
</button>
</ng-container>
【问题讨论】:
标签: angular ionic-framework components ionic4 angular8