I've a checkout page where the user has to login before he can proceed. The user can be logged on already. In every scenario I want to show a spinner when the component detects if the users logged in our not.
The check-out.html code looks like:
<div *ngIf="showSpinner">
<app-spinner></app-spinner>
</div>
<div *ngIf="auth.user | async; then authenticated else guest">
<!-- template will replace this div -->
</div>
<!-- User NOT logged in -->
<ng-template #guest>
<div *ngIf="auth.user == null" class="call-to-action">
login buttons...
</div>
</ng-template>
<!-- User logged in -->
<ng-template #authenticated>
payment staps
</ng-template>
My check-out-component look likes:
export class CheckoutComponent implements OnInit {
private showSpinner = true;
constructor(public auth: AuthService,
private router: Router) {
}
ngOnInit() {
this.auth.user.subscribe(user => {
this.showSpinner = false;
});
}
...
But the the (and the) is always displayed, but I want to load only the spinner and then the #guest or #authenticated. How to accoplish?
If searched a lot but find that the ngIf only can take a if-else construction.