I am using the JS Library with Parse Server and having issues navigating to another page on successful login.
Using this function this.navCtrl.setRoot(TemplatesPage);
doesn't do anything in my app.
My full code is below and I can confirm in the console that the success function is being called and I have also tried pop
before I tried setRoot
.
import { Component } from '@angular/core';
import { NavController, AlertController} from 'ionic-angular';
import { User } from '../../models/user-model';
import { SignupPage } from '../signup/signup';
import { TemplatesPage } from '../templates/templates';
import Parse from 'parse';
@Component({
selector: 'login',
templateUrl: 'login.html'
})
export class LoginPage {
user : User = {
username : '',
password: ''
}
constructor(public navCtrl: NavController, public alertCtrl: AlertController) {
}
login() {
Parse.User.logIn(this.user.username, this.user.password).then(function(user) {
console.log('Success' + user);
this.navCtrl.setRoot(TemplatesPage);
}, function(err) {
this.alertCtrl
.create({title: "Error", message: err.text(), buttons: [{
text: 'OK',
}]})
.present();
})
}
goToTemplatePage() {
this.navCtrl.push(TemplatesPage);
}
gotToSignup() {
this.navCtrl.push(SignupPage);
}
}