Cannot read property 'auth' of undefined


#1
    ERROR TypeError: Cannot read property 'auth' of undefined
    at LoginPage.webpackJsonp.149.LoginPage.login (login.ts:31)
    at Object.eval [as handleEvent] (LoginPage.html:31)
    at handleEvent (core.js:13589)
    at callWithDebugContext (core.js:15098)
    at Object.debugHandleEvent [as handleEvent] (core.js:14685)
    at dispatchEvent (core.js:10004)
    at core.js:10629
    at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (core.js:4751)
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

import { AngularFireAuth } from '@angular/fire/auth';

/**
 * Generated class for the LoginPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {

  email: string;
  password : string; 
  private aAuth : AngularFireAuth;
  constructor(aAuth : AngularFireAuth, public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad LoginPage');
  }

  login(){
   this.aAuth.auth.signInWithEmailAndPassword(this.email, this.password).then(e => {console.log(e)})
  }

}

#2

The error message tells you exactly what is happening. You have never assigned anything to the aAuth property. The most idiomatic solution is to remove the explicit property declaration and simply add the private access qualifier to the constructor parameter, which will cause TypeScript to automatically define and initialize the property.