Skip to content

Instantly share code, notes, and snippets.

@kanon755056
Created April 13, 2018 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanon755056/b62f109c94204e737c9b5dc48685eb63 to your computer and use it in GitHub Desktop.
Save kanon755056/b62f109c94204e737c9b5dc48685eb63 to your computer and use it in GitHub Desktop.
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