import { Component , OnInit } from '@angular/core' ; import { ActivatedRoute } from "@angular/router" ; import { Location } from "@angular/common" ; import { HttpClient } from "@angular/common/http" ; const todoUrl = 'http://localhost:3000/todos' ; @ Component ( { selector : "app-todo" , templateUrl : "./todo.component.html" , styleUrls : [ "./todo.component.css" ] } ) export class TodoComponent implements OnInit { todo : any ; constructor ( private route , private location , private http ) { } ngOnInit ( ) { const id = this . route . snapshot . paramMap . get ( "id" ) ; this . http . get ( `${ todoUrl }/${ id }` ) . subscribe ( todo => ( this . todo = todo ) ) ; } }