Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

angular snapshot get params

import { ActivatedRoute } from "@angular/router";

class Component implements OnInit {
  constructor(private route: ActivatedRoute) { }
  ngOnInit(){
   // Route is: "product/:id"
   const id = this.route.snapshot.paramMap.get("id");
  }
// Caution: "If you intend to update the URL parameter within 
//the same component, then you have to use a subscription."
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #angular #snapshot #params
ADD COMMENT
Topic
Name
2+3 =