import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Task } from '../task'; import { TASKS } from '../tasks.storage'; @Component({ selector: 'app-task', templateUrl: './task.component.html', styleUrls: ['./task.component.css'] }) export class TaskComponent implements OnInit { tasks!: Task; constructor(private activatedRoute: ActivatedRoute) { } ngOnInit(): void { const id = Number(this.activatedRoute.snapshot.paramMap.get('id')); if (id) { this.tasks = TASKS.filter(task => task.id == id)[0]; } } }