>

CODEMASTERYLAB

IDE PLATFORM
CoursesCommunity BlogsKnowledge GraphQuizzesInterview Prep

Sign in to track progress & earn XP

Sign In Create Account
>
Code Mastery Lab

Code Mastery Lab

Sign In

Routing — Navigating a Multi-Page Application

Question 1 / 1

0:00
Core
Medium

A ProductDetailComponent reads the product ID in ngOnInit using this.route.snapshot.paramMap.get('id'). The user navigates from /products/1 to /products/2 by clicking a 'Next Product' link. What happens to the component and why?

typescript export class ProductDetailComponent implements OnInit { product: Product;

ngOnInit(): void { const id = this.route.snapshot.paramMap.get('id'); // reads '1' on first load this.productService.getProductById(id).subscribe(p => this.product = p); } }