import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
selector: 'product-details',
<p>Product Details: {{id}}</p>
<!-- Product information -->
<a [routerLink]="['overview']">Overview</a>
<a [routerLink]="['specs']">Technical Specs</a>
<router-outlet></router-outlet>
<!-- Overview & Specs components get added here by the router -->
export default class ProductDetails implements OnInit, OnDestroy {
constructor(private route: ActivatedRoute) {}
this.sub = this.route.params.subscribe(params => {
this.id = +params['id']; // (+) converts string 'id' to a number