import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router' import { Task, TaskService } from '../task.srv'; @Component({ templateUrl: 'app/view/view.html' }) export class ViewComponent implements OnInit { task: Task; constructor(private route: ActivatedRoute, private router: Router, private taskService: TaskService) {} back() { this.router.navigateByUrl('/list'); } ngOnInit(): void { const id = parseInt(this.route.snapshot.paramMap.get('id')); this.taskService.getTask(id).then(task => this.task = task); } }