Hi, i am using Parse server for my ionic2 app. It works, but the ionic2 function will not working inside Parse server success function.
if(this.repassword==this.password){
var parseuser = new Parse.User();
parseuser.set("username",this.username);
parseuser.set("password",this.password);
parseuser.signUp(null, {:slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile:Here
success: function(user) {
// Hooray! Let them use the app now.
console.log("Register successful"+user.id);
console.log(Parse.User.current());
this.registerSucessAlert();
this.c();
},:slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile::slight_smile:
error: function(user, error) {
// Show the error message somewhere and let the user try again.
alert(error);
}
});
}
else{
this.registerFailAlert("Password is not the same");
}
registerSucessAlert(){
let alert = Alert.create({
title:'Login',
subTitle:'Thank you'+this.username+' for register, Press to Continue.',
buttons:['OK']
});
this.nav.present(alert);
}
c(){
console.log("HI");
}
the result will be
Register successful Vv10l8AqhE
ParseUser{_objCount:0,className:"_User"…blablablablabla
and the alert and c() console will disappear
in the same case, if I rearrange the order.
this.registerSucessAlert();
this.c();
console.log("Register successful"+user.id);
console.log(Parse.User.current());
the alert will also not popup and c is also gone. but the Register successful console are also gone. But the register is successful which can be checked on database.
I have check the alert function is totally work fine if you put outside the Parse function scope. But I want to make sure it only fire on the success request.
Dose ionic2 has any method to monitoring variable change or there are some other way to solve it??