Created
March 6, 2019 07:10
-
-
Save mphuget/58fb01c7186571ff68016eca80b1c281 to your computer and use it in GitHub Desktop.
view page
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, 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