Skip to content

Instantly share code, notes, and snippets.

@mphuget
Created March 6, 2019 07:10
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/58fb01c7186571ff68016eca80b1c281 to your computer and use it in GitHub Desktop.
Save mphuget/58fb01c7186571ff68016eca80b1c281 to your computer and use it in GitHub Desktop.
view page
import { Component, OnInit } from '@angular/core';
import { LoadingController } from '@ionic/angular';
import { RestService } from '../rest.service';
import { ActivatedRoute, ParamMap } from '@angular/router';
@Component({
selector: 'app-view',
templateUrl: './view.page.html',
styleUrls: ['./view.page.scss'],
})
export class ViewPage implements OnInit {
todo : any;
api : RestService;
id : string;
constructor(public restapi: RestService, public loadingController: LoadingController, private route: ActivatedRoute) {
this.api = restapi;
}
async getTodo() {
const loading = await this.loadingController.create({
message: 'Loading'
});
await loading.present();
await this.api.getTodo(this.id)
.subscribe(res => {
console.log(res);
this.todo = res[0];
loading.dismiss();
}, err => {
console.log(err);
loading.dismiss();
});
}
save() {
}
delete() {
}
ngOnInit() {
this.route.paramMap.subscribe((params : ParamMap)=> {
this.id=params.get('id');
});
console.log("Current id: " + this.id);
this.getTodo(this.id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment