Skip to content

Instantly share code, notes, and snippets.

Last active July 25, 2017 21:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
<ion-navbar hideBackButton="true">
<ion-title>Iniciar Sesión</ion-title>
<form [formGroup]="signInForm">
<ion-label stacked>Correo electrónico</ion-label>
<ion-input type="email" formControlName="email" autocorrect="off" autocapitalize="none"></ion-input>
<ion-label stacked>Contraseña</ion-label>
<ion-input type="password" formControlName="password"></ion-input>
<ion-label stacked>Nombre</ion-label>
<ion-input type="text" formControlName="firstName" autocorrect="off"></ion-input>
<div padding-left padding-right padding-top>
<button ion-button [disabled]="!signInForm.valid" (click)="signIn()" block>Entrar</button>
import { Component } from '@angular/core';
import { NavController, LoadingController, AlertController } from 'ionic-angular';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { AuthService } from '../../providers/auth-service';
import { UserModel } from '../../models/user-model';
import { SignUpPage } from '../signup/signup';
import { HomePage } from '../home/home';
selector: 'page-signin',
templateUrl: 'signin.html'
export class SignInPage {
private signInForm: FormGroup;
public navCtrl: NavController,
public loadingCtrl: LoadingController,
public alertCtrl: AlertController,
public authService: AuthService,
private formBuilder: FormBuilder) {
this.signInForm ={
email: ['', Validators.compose([Validators.required, Validators.pattern('[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$')])],
password: ['', Validators.compose([Validators.required, Validators.minLength(6)])],
firstName: ['', Validators.required]
signIn() {
let loading = this.loadingCtrl.create({
content: 'Iniciando sesión. Por favor, espere...'
let userModel = new UserModel(); =;
userModel.password =;
userModel.firtName = this.signInForm.value.firtName;
this.authService.signInWithEmailAndPassword(userModel).then(result => {
}).catch(error => {
this.alert('Error', 'Ha ocurrido un error inesperado. Por favor intente nuevamente.');
signUp() {
alert(title: string, message: string) {
let alert = this.alertCtrl.create({
title: title,
subTitle: message,
buttons: ['OK']
export class UserModel {
email: string;
password: string;
firtName: string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment