如何在angular 5模板中实现以下目标:
<h6>{{userWalletData.BTCWalletBalance ? {{userWalletData.BTCWalletBalance}} BTC = {{userWalletData.BTCWalletBalanceInFiat}} : 'Fetching balance...'}}</h6>
答案 0 :(得分:2)
You can use Angular's *ngIf in the template to achieve it.
<h6 *ngIf="userWalletData.BTCWalletBalance != undefined && userWalletData.BTCWalletBalanceInFiat != undefined; else fetching_balance">{{userWalletData.BTCWalletBalance}} BTC = {{userWalletData.BTCWalletBalanceInFiat}}</h6>
<ng-template #fetching_balance><span>Fetching balance...</span></ng-template>
hope it helps!