Skip to content

Commit ddac9c6

Browse files
committed
Step 14.8: Use getSMS method in verification.ts
1 parent be2a408 commit ddac9c6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/pages/verification/verification.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { AfterContentInit, Component, OnInit } from '@angular/core';
22
import { AlertController, NavController, NavParams } from 'ionic-angular';
33
import { PhoneService } from '../../services/phone';
44
import { ProfilePage } from '../profile/profile';
@@ -7,7 +7,7 @@ import { ProfilePage } from '../profile/profile';
77
selector: 'verification',
88
templateUrl: 'verification.html'
99
})
10-
export class VerificationPage implements OnInit {
10+
export class VerificationPage implements OnInit, AfterContentInit {
1111
private code: string = '';
1212
private phone: string;
1313

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

25+
ngAfterContentInit() {
26+
this.phoneService.getSMS()
27+
.then((code: string) => {
28+
this.code = code;
29+
this.verify();
30+
})
31+
.catch((e: Error) => {
32+
if (e) {
33+
console.error(e.message);
34+
}
35+
});
36+
}
37+
2538
onInputKeypress({keyCode}: KeyboardEvent): void {
2639
if (keyCode === 13) {
2740
this.verify();

0 commit comments

Comments
 (0)