Hi, I,m using ionic 4 to build a mobile apps. I got an error when I try to connect login and signup with firebase. But I got error Property ‘alert’ does not exist on type ‘LoginPage’ at line const alert = await this.alert.create. Can anyone help me with this?
import { Component, ViewEncapsulation } from '@angular/core';
import { NgForm } from '@angular/forms';
import { Router } from '@angular/router';
import { AngularFireAuth } from '@angular/fire/auth'
import { auth } from 'firebase/app'
import{ AlertController } from '@ionic/angular'
import { UserData } from '../../providers/user-data';
import { UserOptions } from '../../interfaces/user-options';
@Component({
selector: 'page-login',
templateUrl: 'login.html',
styleUrls: ['./login.scss'],
})
export class LoginPage {
login: UserOptions = { username: '', password: '', copassword:'' };
submitted = false;
constructor(
public afAuth: AngularFireAuth,
public userData: UserData,
public router: Router,
) { }
async onlogin (username: string, password: string) {
this.submitted = true;
try{
const res = await this.afAuth.auth.signInWithEmailAndPassword(username +'@codedamn.com',password)
console.log(res)
this.router.navigate(['/tabs'])
} catch(error){
console.dir(error)
this.showAlert("Error", "User not found")
if (error.code =="auth/user-not-found"){
console.log("User not found")
}
}
}
async showAlert(header: string, message: string) {
const alert = await this.alert.create ({ // error is here
header,
message,
buttons: ["Ok"]
})
await alert.present()
}
}