I'm using
Angular 5.2
Firestore
Using *ngIf isContent else noContent
, I am trying to render an Observable only if it's populated with data. The logic isn't hitting the else statement. It's rendering isContent
even when there's no data. I have poured through these similar stack overflow questions and it looks like my syntax is correct. What am I doing wrong?
Here's the code.
<ng-container *ngIf="months2025 | async as months; else nocontent">
#### RENDERING REGARDLESS OF MONTHS2025 ####
<div class="column">
<h1>2025</h1> #### <-- THIS SHOWS UP ####
<ul>
<li *ngFor="let month of months">
<a href={{month.url}}> {{ month.fileName }} </a>
</li>
</ul>
</div>
</ng-container>
#### NOT RENDERING WHEN NOCONTENT ####
<ng-template #nocontent>
</ng-template>
Here is the component.ts
export class MinutesComponent {
monthsArray2025: AngularFirestoreCollection<any>;
months2025: Observable<any[]>;
constructor(private afs: AngularFirestore) {
this.monthsArray2025 = afs.collection<any>('minutes', ref => ref.where('year', '==', 2025);
this.months2025 = this.monthsArray2025.valueChanges();
}
}