回答:
Angular 4および5:
を使用してelse:
<div *ngIf="isValid;else other_content">
    content here ...
</div>
<ng-template #other_content>other content here...</ng-template>
あなたも使うことができますthen else:
<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一人で:
<div *ngIf="isValid;then content"></div>    
<ng-template #content>content here...</ng-template>
デモ :
詳細:
<ng-template>:MDNに<template>準拠したタグのAngular独自の実装です。
HTML
<template>要素は、ページが読み込まれたときにレンダリングされないが、実行時にJavaScriptを使用してインスタンス化されるクライアント側コンテンツを保持するためのメカニズムです。
<ng-container>if句に使用できます
                    ng-container* ngIfを含むコンテナには使用できますが、テンプレートには使用できません
                    *ngIf 仕事をすることを許可しなかったのng-templateですか?
                    Angular 4.xx では、ngIfを4つの方法で 使用して、単純なif else手順を実現できます。
ただ、使用する場合
<div *ngIf="isValid">
    If isValid is true
</div>
ElseでのIfの使用(templateNameに注意してください)
<div *ngIf="isValid; else templateName">
    If isValid is true
</div>
<ng-template #templateName>
    If isValid is false
</ng-template>
ThenでのIfの使用(templateNameに注意してください)
<div *ngIf="isValid; then templateName">
    Here is never showing
</div>
<ng-template #templateName>
    If isValid is true
</ng-template>
ThenおよびElseでのIfの使用
<div *ngIf="isValid; then thenTemplateName else elseTemplateName">
    Here is never showing
</div>
<ng-template #thenTemplateName>
    If isValid is true
</ng-template>
<ng-template #elseTemplateName>
    If isValid is false
</ng-template>
ヒント:ngIfは式を評価し、 式が真または偽の場合、thenまたはelseテンプレートをそれぞれその場所にレンダリングします。通常は次のとおりです。
- その後、テンプレートはインラインテンプレートですngIf異なる値にバインドされていない限り。
 - 他に、それがバインドされていない限り、テンプレートが空白になっています。
 
...; else ...です。おそらく;削除する必要があります。
                    ...; else ...てそれが機能しました
                    「bindEmail」はメールが利用可能かどうかをチェックします。メールが存在する場合はログアウトが表示され、それ以外の場合はログインが表示されます
<li *ngIf="bindEmail;then logout else login"></li>
<ng-template #logout><li><a routerLink="/logout">Logout</a></li></ng-template>
<ng-template #login><li><a routerLink="/login">Login</a></li></ng-template>
              あなたはこれを使用<ng-container>し<ng-template>て達成することができます
<ng-container *ngIf="isValid; then template1 else template2"></ng-container>
<ng-template #template1>
     <div>Template 1 contains</div>
</ng-template>
<ng-template #template2>
     <div>Template 2 contains </div>
</ng-template>
以下のStackblitz Liveデモを見つけることができます
これが役に立てば幸い... !!!
以下のための角度9/8
例のあるソースリンク
    export class AppComponent {
      isDone = true;
    }
1)* ngIf
    <div *ngIf="isDone">
      It's Done!
    </div>
    <!-- Negation operator-->
    <div *ngIf="!isDone">
      It's Not Done!
    </div>
2)* ngIfおよびElse
    <ng-container *ngIf="isDone; else elseNotDone">
      It's Done!
    </ng-container>
    <ng-template #elseNotDone>
      It's Not Done!
    </ng-template>
3)* ngIf、Then、Else
    <ng-container *ngIf="isDone;  then iAmDone; else iAmNotDone">
    </ng-container>
    <ng-template #iAmDone>
      It's Done!
    </ng-template>
    <ng-template #iAmNotDone>
      It's Not Done!
    </ng-template>
              <div *ngIf=”condition; else elseBlock”>Truthy condition</div>
<ng-template #elseBlock>Falsy condition</ng-template>
テンプレートを追加するには、テンプレートに明示的にバインドする必要があります。
<div *ngIf=”condition; then thenBlock else elseBlock”> ... </div> 
<ng-template #thenBlock>Then template</ng-template>
<ng-template #elseBlock>Else template</ng-template>
Angular 8から新しいアップデートを追加するだけです。
<ng-template [ngIf]="condition" [ngIfElse]="elseBlock">
  Content to render when condition is true.
</ng-template>
<ng-template #elseBlock>
  Content to render when condition is false.
</ng-template>
<ng-template [ngIf]="condition" [ngIfThen]="thenBlock">
  This content is never showing
</ng-template>
<ng-template #thenBlock>
  Content to render when condition is true.
</ng-template>
<ng-template [ngIf]="condition" [ngIfThen]="thenBlock" [ngIfElse]="elseBlock">
  This content is never showing
</ng-template>
<ng-template #thenBlock>
  Content to render when condition is true.
</ng-template>
<ng-template #elseBlock>
  Content to render when condition is false.
</ng-template>
              Angular 4.0では、if..else構文はJavaの条件演算子に非常に似ています。
Javaではに使用し"condition?stmnt1:stmnt2"ます。
Angular 4.0ではを使用します*ngIf="condition;then stmnt1 else stmnt2"。
ngif式の結果の値は、ブール値のtrueまたはfalseだけではありません
式が単なるオブジェクトの場合でも、それは真実であると評価します。
オブジェクトが未定義または存在しない場合、ngifはそれを偽りと評価します。
一般的な使用法は、オブジェクトがロードされて存在する場合は、このオブジェクトのコンテンツを表示し、それ以外の場合は「loading .......」を表示します。
 <div *ngIf="!object">
     Still loading...........
 </div>
<div *ngIf="object">
     <!-- the content of this object -->
           object.info, object.id, object.name ... etc.
 </div>
もう一つの例:
  things = {
 car: 'Honda',
 shoes: 'Nike',
 shirt: 'Tom Ford',
 watch: 'Timex'
 };
 <div *ngIf="things.car; else noCar">
  Nice car!
 </div>
<ng-template #noCar>
   Call a Uber.
</ng-template>
 <!-- Nice car ! -->
anthoerの例:
<div *ngIf="things.car; let car">
   Nice {{ car }}!
 </div>
<!-- Nice Honda! -->
              <div *ngIf="this.model.SerialNumber != '';then ConnectedContent else DisconnectedContent" class="data-font">    </div>
<ng-template #ConnectedContent class="data-font">Connected</ng-template>
<ng-template #DisconnectedContent class="data-font">Disconnected</ng-template>
              テンプレート参照変数 [2]を作成し、それを* ngIfディレクティブ内のelse条件にリンクするだけです。
可能な構文 [1]は次のとおりです。
<!-- Only If condition -->
<div *ngIf="condition">...</div>
<!-- or -->
<ng-template [ngIf]="condition"><div>...</div></ng-template>
<!-- If and else conditions -->
<div *ngIf="condition; else elseBlock">...</div>
<!-- or -->
<ng-template #elseBlock>...</ng-template>
<!-- If-then-else -->
<div *ngIf="condition; then thenBlock else elseBlock"></div>
<ng-template #thenBlock>...</ng-template>
<ng-template #elseBlock>...</ng-template>
<!-- If and else conditions (storing condition value locally) -->
<div *ngIf="condition as value; else elseBlock">{{value}}</div>
<ng-template #elseBlock>...</ng-template>
デモ: https : //stackblitz.com/edit/angular-feumnt? embed =1& file=src/app/ app.component.html
出典:
JavaScriptの短い3項条件演算子を使用することもできますか?このような角度で:
{{doThis() ? 'foo' : 'bar'}}
または
<div [ngClass]="doThis() ? 'foo' : 'bar'">
              これはしばらく前からわかっていますが、役に立った場合は追加したいと思います。私が行った方法は、コンポーネントに2つのフラグを設定し、対応する2つのフラグに2つのngIfを設定することです。
ng-templateとマテリアルがうまく機能しないため、シンプルでマテリアルとうまく機能しました。