title: How to get id from the URL using snapshot or ActivatedRoute subscriber in Angular?
body: <p>I am getting value using snapshot method but it is getting the value after &quot;classes&quot; in this case 20 but I need 33 path like getting</p>
  <pre><code>credits/33/classes/20 only 20 or credits/33/classes/ only null(&quot;&quot;)
  </code></pre>
  <p><strong>Update</strong>:
  I found a solution to my question.</p>
  <p>Now it is getting id properly. The mistake is accessing to element in the right child component, didn't work in child's MatDialog component within the Snapshot version.</p>
  <pre><code>constructor(private route: ActivatedRoute) {} 
   ngOnInit(): void {
     console.log(parseInt(this.route.snapshot.paramMap.get('id1')));
  </code></pre>
  <blockquote>
  <p>If your url has 2 Id values, you can use snapshot of route.parent</p>
  </blockquote>
  <pre><code>   console.log(parseInt(this.route.parent.snapshot.paramMap.get('id1')));
  }
  </code></pre>