This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { NavController, LoadingController, AlertController } from 'ionic-angular'; | |
import { AuthService } from '../../providers/auth-service'; | |
import { UserModel } from '../../models/user-model'; | |
import { SignInPage } from '../signin/signin'; | |
@Component({ | |
selector: 'page-signup', | |
templateUrl: 'signup.html' | |
}) | |
export class SignUpPage { | |
userModel: UserModel; | |
constructor( | |
public navCtrl: NavController, | |
public loadingCtrl: LoadingController, | |
public alertCtrl: AlertController, | |
public authService: AuthService) { | |
this.userModel = new UserModel(); | |
} | |
signUp() { | |
let loading = this.loadingCtrl.create({ | |
content: 'Creando cuenta. Por favor, espere...' | |
}); | |
loading.present(); | |
this.authService.createUserWithEmailAndPassword(this.userModel).then(result => { | |
loading.dismiss(); | |
this.navCtrl.push(SignInPage); | |
}).catch(error => { | |
loading.dismiss(); | |
console.log(error); | |
this.alert('Error', 'Ha ocurrido un error inesperado. Por favor intente nuevamente.'); | |
}); | |
} | |
alert(title: string, message: string) { | |
let alert = this.alertCtrl.create({ | |
title: title, | |
subTitle: message, | |
buttons: ['OK'] | |
}); | |
alert.present(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment