Permalink
Browse files

Step 7.16: Added verification component

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent afd7cd0 commit 9ab38187453847e7a5bb36a47ff9c594a588d2bb
Showing with 48 additions and 0 deletions.
  1. +48 −0 src/pages/verification/verification.ts
@@ -0,0 +1,48 @@
import { Component, OnInit } from '@angular/core';
import { AlertController, NavController, NavParams } from 'ionic-angular';
import { PhoneService } from '../../services/phone';
@Component({
selector: 'verification',
templateUrl: 'verification.html'
})
export class VerificationPage implements OnInit {
private code: string = '';
private phone: string;
constructor(
private alertCtrl: AlertController,
private navCtrl: NavController,
private navParams: NavParams,
private phoneService: PhoneService
) {}
ngOnInit() {
this.phone = this.navParams.get('phone');
}
onInputKeypress({keyCode}: KeyboardEvent): void {
if (keyCode === 13) {
this.verify();
}
}
verify(): void {
this.phoneService.login(this.phone, this.code)
.catch((e) => {
this.handleError(e);
});
}
handleError(e: Error): void {
console.error(e);
const alert = this.alertCtrl.create({
title: 'Oops!',
message: e.message,
buttons: ['OK']
});
alert.present();
}
}

0 comments on commit 9ab3818

Please sign in to comment.