使用 else :code
<div *ngIf="isValid;else other_content"> content here ... </div> <ng-template #other_content>other content here...</ng-template>
你也可使用 then else :get
<div *ngIf="isValid;then content else other_content">here is ignored</div> <ng-template #content>content here...</ng-template> <ng-template #other_content>other content here...</ng-template>
或者使用單獨的 then :it
<div *ngIf="isValid;then content"></div> <ng-template #content>content here...</ng-template>
Demo示例 :di
Plunkerco