How to redirect after .createUser while using meteor-angular


#1

Hi, I’m building a mobile app with meteor + angular + ionic. To create users i’m using accounts:password. Currently I create users like this:
createUser() { if(this.user.password != this.password_repeat) { this.handleError("Passwords don't match"); return false; } this.user.profile.email = this.user.email; this.$meteor.createUser(this.user).then(function(){ console.log('Login success'); return true; }, function(err){ console.log('Login error - ', err); return false; }); }

This method is located in a controller that’s built based on angular-meteor whatsapp tutorial. What i want to achieve is to redirect users to another page if the user creation is successful. Otherwise I want a ionicPopup to appear.
The problem: it seems that I cannot change the $state (via $state.go() ) in the callback functions, because it’s not accessible from there. Neither is $ionPopup generator. I can invoke these things outside of the callback.
The question: what is the right way to redirect users after a successful signup in this situation?

Thanks in advance!