import { Component , OnInit } from '@angular/core' ; import { AlertController , NavController , NavParams } from 'ionic-angular' ; import { ProfilePage } from '../profile/profile' ; import { PhoneService } from '../../services/phone' ; import template from './verification.html' ; @ Component ( { template } ) export class VerificationPage implements OnInit { code : string = '' ; phone : string ; constructor ( private alertCtrl , private navCtrl , private navParams , private phoneService ) { } ngOnInit ( ) { this . phone = this . navParams . get ( 'phone' ) ; } onInputKeypress ( { keyCode } ) { if ( keyCode === 13 ) { this . verify ( ) ; } } verify ( ) { this . phoneService . login ( this . phone , this . code ) . then ( ( ) => { this . navCtrl . setRoot ( ProfilePage , { } , { animate : true } ) ; } ) ; } handleError ( e ) { console . error ( e ) ; const alert = this . alertCtrl . create ( { title : 'Oops!' , message : e . message , buttons : [ 'OK' ] } ) ; alert . present ( ) ; } }