I'm attempting to troubleshoot an issue and have written the following code to see what is going on, but now I am even further confused. Ideally if entry.customer
has a value it should be printed and then Hello
should also be displayed, otherwise NOPE
and Goodbye
should be displayed, but the actual result is that only the value of entry.customer
is displayed.
<h3>{{entry.customer}}</h3>
<span *ngIf="entry.customer else no">
<h1>Hello</h1>
</span>
<ng-template #no>
<h1> NOPE</h1>
</ng-template>
<span *ngIf="!entry.customer">
<h1>Goodbye</h1>
</span>
<h3> {{entry.customer}} </h3>
<span *ngIf="entry.customer else no">
<h1>Hello</h1>
</span>
<ng-template #no>
<h1> NOPE</h1>
</ng-template>
<span *ngIf="!entry.customer">
<h1>Goodbye</h1>
</span>
When I started tracking down this issue I thought that maybe there was an issue with change detection due to the value of entry coming from a BehaviorSubject, so I attempted getting the values in a zone, but that didn't change the result.
ngOnInit(): void {
this.ngZone.run(() => {
debugger;
this._entryService.entry.subscribe(entry => {
debugger;
this.entry = entry;
});
})
}
Can anyone explain a possible reason why *ngIf won't work, yet using the curly braces does display the value? If it helps any the component that I am using is extended from a base component that gets the value of entry as there are many components of the same type in this application.