My event emitter is not functioning properly within a promise's then method. No errors are being generated, it just won't execute.
In the child component:
@Output() isLoggingIn = new EventEmitter<boolean>();
onLogin() {
this.isLoggingIn.emit(true); //<-- This works.
this.authService.loginUser(this.loginForm.value)
.then( () => {
console.log(this.isLoggingIn.emit); //<-- Method gets logged.
this.isLoggingIn.emit(false); //<-- This does not work!
})
.catch( (err) => console.log(err) );
}
This is the HTML template of the parent component, header.component.html:
<tas-loginform
(isLoggingIn)="setLoginLoading($event)"
*ngIf="!isSigningUp">
</tas-loginform>
This is the TypeScript code of the parent component, header.component.ts:
setLoginLoading(bool: boolean) {
console.log(bool);
this.loginLoading = bool;
}
The Event Emitter in the promise's .then callback seems to never be called at all since the console.log in setLoginLoading is not executed. The lack of error messages adds to the confusion.