Created
October 9, 2019 07:22
-
-
Save mphuget/d51a98bfc3c1641ab301fa3c73c670b9 to your computer and use it in GitHub Desktop.
home.page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { LoadingController, NavController } from '@ionic/angular'; | |
import { RestService } from '../rest.service'; | |
@Component({ | |
selector: 'app-home', | |
templateUrl: 'home.page.html', | |
styleUrls: ['home.page.scss'], | |
}) | |
export class HomePage { | |
todos : any; | |
api : RestService; | |
constructor(public restapi: RestService, public loadingController: LoadingController, public navController : NavController) { | |
this.api = restapi; | |
} | |
async getTodos() { | |
const loading = await this.loadingController.create({ | |
message: 'Loading' | |
}); | |
await loading.present(); | |
await this.api.getTodos() | |
.subscribe(res => { | |
console.log(res); | |
this.todos = res; | |
loading.dismiss(); | |
}, err => { | |
console.log(err); | |
loading.dismiss(); | |
}); | |
} | |
done(id: any) { | |
console.log("done"); | |
} | |
delete(id:any) { | |
console.log("delete"); | |
} | |
ngOnInit() { | |
this.getTodos(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment