Retrieving Angular URL Parameters

Image by ElinaElena from Pixabay

Scenario

{ path: "todos/:id", component: TodoComponent }

Approach

import { ActivatedRoute } from "@angular/router";constructor(private route: ActivatedRoute) {}ngOnInit() { 
//Get the snapshot (One time only)
this.id = this.route.snapshot.paramMap.get("id")}
//Subscribe (Dynamic URL Updates)
this.route.paramMap.subscribe( params => {
this.id = params.get("id")
})