0

i try to direct the user directly to a new component, if the user is already signed in. Unfortunately i receive always the error "goPersonalData is not a function". Maybe someone could help me:

ngOnInit() {
firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    this.goPersonalData();
  } else {


  }
});

}
onSubmit(form: NgForm) {
const email = form.value.email;
const password = form.value.password;

this.authService.login(email, password);

}
goPersonalData() {
this.router.navigate(['/personalData']);
 }



  }
Dominik
  • 419
  • 2
  • 6
  • 16
  • I don't know what you do before, but do you think bind your function `goPersonalData()` into your class constructor ? – KolaCaine Aug 14 '18 at 11:21
  • this is my constructor constructor(private router: Router , private authService: AuthService ) { } – Dominik Aug 14 '18 at 11:46
  • You need to bind your function into your constructor. `this.goPersonalData = this.goPersonalData.bind(this)` – KolaCaine Aug 14 '18 at 14:58

0 Answers0