Skip to content

Commit

Permalink
Step 14.8: Use getSMS method in verification.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
darkbasic committed Oct 16, 2017
1 parent be2a408 commit ddac9c6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/pages/verification/verification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { AfterContentInit, Component, OnInit } from '@angular/core';
import { AlertController, NavController, NavParams } from 'ionic-angular';
import { PhoneService } from '../../services/phone';
import { ProfilePage } from '../profile/profile';
Expand All @@ -7,7 +7,7 @@ import { ProfilePage } from '../profile/profile';
selector: 'verification',
templateUrl: 'verification.html'
})
export class VerificationPage implements OnInit {
export class VerificationPage implements OnInit, AfterContentInit {
private code: string = '';
private phone: string;

Expand All @@ -22,6 +22,19 @@ export class VerificationPage implements OnInit {
this.phone = this.navParams.get('phone');
}

ngAfterContentInit() {
this.phoneService.getSMS()
.then((code: string) => {
this.code = code;
this.verify();
})
.catch((e: Error) => {
if (e) {
console.error(e.message);
}
});
}

onInputKeypress({keyCode}: KeyboardEvent): void {
if (keyCode === 13) {
this.verify();
Expand Down

0 comments on commit ddac9c6

Please sign in to comment.