Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(
public navCtrl: NavController
) {
console.log('start')
/****************
* call C()
****************/
c()
function d() {
return new Promise((resolve, reject) => {
setTimeout(() =>{
resolve('success')
}, 5000)
})
}
async function c() {
let re = await d()
console.log('re =', re)
}
}
ionViewDidLoad() {
/****************
* call a()
****************/
this.a();
let i = 0
setInterval(() =>{
i++
console.log('second =', i)
}, 1000)
}
b() {
return new Promise((resolve, reject) => {
setTimeout(() =>{
resolve('success')
}, 5000)
})
}
async a() {
let re = await this.b()
console.log('re =', re)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment