Created
February 18, 2020 10:05
-
-
Save mphuget/944364db642124ddc5f2fa482d2ee2a4 to your computer and use it in GitHub Desktop.
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(id:any) { | |
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