# Page cannot find a function from a provider

**URL:** <https://forum.ionicframework.com/t/page-cannot-find-a-function-from-a-provider/73644>\
**Category:** ionic-v3\
**Created:** [December 18, 2016, 3:47pm UTC](https://forum.ionicframework.com/t/page-cannot-find-a-function-from-a-provider/73644 "2016-12-18T15:47:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![krowar](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@krowar](https://forum.ionicframework.com/u/krowar)\
**Post date:** [December 18, 2016, 3:47pm UTC](https://forum.ionicframework.com/t/page-cannot-find-a-function-from-a-provider/73644/1 "2016-12-18T15:47:12Z")

</div>

Hi all,

I’m following this tutorial : [https://javebratt.com/angularfire2-email-auth/](https://javebratt.com/angularfire2-email-auth/) and I get a weird error.

I’m at the login page implementation, and I have already implemented these two files

login.ts

```
import {
  NavController,
  LoadingController,
  AlertController
} from 'ionic-angular';
import { Component } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { AuthData } from '../../providers/auth-data';

import { Page1 } from '../../pages/page1/page1';
import { SignupPage } from '../../pages/signup/signup';
import { ResetPasswordPage } from '../../pages/reset-password/reset-password';

import { EmailValidator } from '../../validators/email';

/*
  Generated class for the Login page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-login',
  templateUrl: 'login.html'
})
export class LoginPage {
  public loginForm: any;
  emailChanged: boolean = false;
  passwordChanged: boolean = false;
  submitAttempt: boolean = false;
  public loading: any;

  constructor(public nav: NavController, public authData: AuthData,
public formBuilder: FormBuilder, public alertCtrl: AlertController,
public loadingCtrl: LoadingController) {
    this.loginForm = formBuilder.group({
      email: ['', Validators.compose([Validators.required, 
        EmailValidator.isValid])],
      password: ['', Validators.compose([Validators.minLength(6), 
      Validators.required])]
    });
  }

  goToResetPassword(){
    this.nav.push(ResetPasswordPage);
  }

  createAccount(){
    this.nav.push(SignupPage);
  }

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

  elementChanged(input){
    let field = input.inputControl.name;
    this[field + "Changed"] = true;
  }

  loginUser(){
      this.submitAttempt = true;

      if (!this.loginForm.valid){
        console.log(this.loginForm.value);
      } else {
        this.authData.loginUser(this.loginForm.value.email, 
          this.loginForm.value.password).then( authData => {
            this.nav.setRoot(Page1);
      }, error => {
        this.loading.dismiss().then( () => {
          let alert = this.alertCtrl.create({
            message: error.message,
            buttons: [
            {
              text: "Ok",
              role: 'cancel'
            }
            ]
          });
        alert.present();
        });
      });

      this.loading = this.loadingCtrl.create({
        dismissOnPageChange: true,
      });
      this.loading.present();
      }
  }

}

```

and auth-data.ts

```
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';

import { AngularFire } from 'angularfire2';

@Injectable()
export class AuthData {
  fireAuth: any;
  constructor(public af:AngularFire) {
    console.log('Hello AuthData Provider');
    af.auth.subscribe(user => {
        if(user){
            this.fireAuth = user.auth;
            console.log(user);
        }
    })
  }
  loginUser(newEmail: string, newPassword: string): any {
    return this.af.auth.login({ email: newEmail, password: newPassword });
  }

  resetPassword(email: string): any {
    return firebase.auth().sendPasswordResetEmail(email);
  }

  logoutUser(): any {
    return this.af.auth.logout();
  }

  signupUser(newEmail: string, newPassword: string): any {
    return this.af.auth.createUser({ email: newEmail, password: newPassword });
  }
}

```

But when I do ‘ionic serve’ I get the following weird error about by login.ts

> Property ‘loginUser’ does not exist on type ‘AuthData’

This loginUser function is here in my auth-data.ts , so I don’t understand what it means .

My guess would have been that ‘this.authData’ is never initiated, but even when I add `this.authData = authData` in the constructor, it does not change anything. (that also says that I don’t understand how it gets initiated)

Does anyone know why I get this loginUser error ?

Thanks a lot

---

<div class="post-metadata">

**Author:** ![n1t1nv3rma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@n1t1nv3rma](https://forum.ionicframework.com/u/n1t1nv3rma)\
**Post date:** [January 12, 2017, 12:08pm UTC](https://forum.ionicframework.com/t/page-cannot-find-a-function-from-a-provider/73644/2 "2017-01-12T12:08:23Z")

</div>

Any luck? I am sort of having same error ☹

---

<div class="post-metadata">

**Author:** ![chrisbenseler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/chrisbenseler/32/90788_2.png) [@chrisbenseler](https://forum.ionicframework.com/u/chrisbenseler)\
**Post date:** [January 12, 2017, 1:51pm UTC](https://forum.ionicframework.com/t/page-cannot-find-a-function-from-a-provider/73644/3 "2017-01-12T13:51:51Z")

</div>

Is AuthData in the _providers_ array from @NgModule (app.module.ts)?
