title: Check if variable is undefined with *ngIf
body: <p>I have the following on an Angular 7 application:</p>
  
  <pre><code>&lt;ng-container *ngIf="(post$ | async) as post; else loader"&gt;
    &lt;div *ngIf="post; else empty"&gt;
      Post content
    &lt;/div&gt;
  &lt;/ng-container&gt;
  &lt;ng-template #empty&gt;
    Post not found
  &lt;/ng-template&gt;
  &lt;ng-template #loader&gt;
    Loading post
  &lt;/ng-template&gt;
  </code></pre>
  
  <p>This works fine when post is defined ...</p>
  
  <p>However when <code>post</code> is undefined the "Post not Found" does not show ...</p>
  
  <p>... I just see the Loading message which does not disappears.</p>
  
  <p>What am I missing?</p>
  
  <p><strong>Update</strong> </p>
  
  <p>post$ is defined as follows in the component:</p>
  
  <p><strong>Note:</strong> post$ is not an array. See <strong>envelope.result[0]</strong> in the code.</p>
  
  <pre><code>export class PostDetailComponent implements OnInit {
  
    @Input() postId: number;
  
    post$: Observable&lt;PostDetailModel&gt;;
  
    constructor(private postService: PostService) { }
  
    ngOnInit() {
  
      this.post$ = this.getPost();
  
    }
  
    getPost(): Observable&lt;PostDetailModel&gt; {
  
      return this.postService.getByPostId(this.postId).pipe(
  
        map((envelope: Envelope&lt;GetByPostIdResponse&gt;) =&gt; envelope.result[0]),
  
        map((response: GetByPostIdResponse) =&gt; {
  
          return response == null ? null : {
            id: response.id,
            title: response.title
            // other properties
          };
  
        }));
  
    }
  </code></pre>