Skip to content

Instantly share code, notes, and snippets.

@mphuget
Created February 19, 2019 13:16
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 mphuget/41d77dddec55ff8722d95defbc5494bf to your computer and use it in GitHub Desktop.
Save mphuget/41d77dddec55ff8722d95defbc5494bf to your computer and use it in GitHub Desktop.
home.page.ts
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