I have a very basic Ionic Android app using firebase authentication. When the user enter wrong credentials and I catch an error I simply change a reactive property to display the error to user:
async login() {
try {
await this.authService.login(this.email, this.password);
this.error = "";
} catch (error) {
this.error = error;
}
}
This functino is called when clicking on login button and the function login in authService looks like this :
login(email: string, password: string) {
return this.afAuth.signInWithEmailAndPassword(email, password);
}
And in my login html page I am trying to display the error like this :
<p>
<ion-text color="danger"><i>{{error}}</i></ion-text>
</p>
Everything is basic nothing fancy, and everythings works perfectly in a browser if I run the app via ionic serve
, but it's does not work the same on an Android device after running the app ionic cordova run android
.
If the credentials are wrong the error is well catched but not displayed on the interface, unless I click on an input then the error is displayed. I believe that Angular does not detect change, and by using ChangeDetectorRef
as described in this solution here it works.
But I find it a hacky way to solve this bug. Why can't angular detect the change itself? why it's working on a browser but not on the mobile device?
I've checked many other similar problems but no one got the issue that it's working on a browser but not on an Android device.