Creating a class named UserData to retrieve input values from forms, I then create another class called LoginData with the same values but for a different purpose. When I console.log
userData, everything works fine. However, when I try to console.log
loginData, it shows as null
.
constructor(private alertCtrl: AlertController, public navCtrl:
NavController, public navParams: NavParams, public authService:
UserProvider, public loadingCtrl: LoadingController, private toastCtrl:
ToastController) {
console.log(this.loginData)
}
userData = {
"name": "",
"email": "" ,
"Type_Id" : "",
"Mobile" : "",
"password": "",
};
loginData = {
UserEmail: this.userData.name ,
Password: this.userData.email
}
signup(){
this.showLoader();
console.log(this.loginData)
this.authService.postData(this.userData,'Regestier').then((result) => {
var userinfo = this.responseData;
console.log(this.responseData);
localStorage.setItem('userinfo', this.responseData);
this.login()
/* if (this.responseData.Type_Id = "1"){
this.navCtrl.push(CompanyProfilePage, {}, {animate: true, direction:
'forward'});
}
else
{
this.navCtrl.setRoot(DashboardPage, {}, {animate: true, direction:
'forward'});
}*/
this.loading.dismiss();
this.presentPrompt()
},
(err) => {
// Error log
this.loading.dismiss();
});
}
I aim to use UserData to save sign up form Data and LoginData for storing login Data. While sign up is functioning correctly, there seems to be an issue with loginData returning null
.