Skip to content

Commit

Permalink
Step 7.16: Added verification component
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and darkbasic committed Oct 16, 2017
1 parent afd7cd0 commit 9ab3818
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions 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.