diff --git a/aio/content/examples/getting-started/src/app/product-details/product-details.component.1.ts b/aio/content/examples/getting-started/src/app/product-details/product-details.component.1.ts index 78add76808..413ad547e5 100644 --- a/aio/content/examples/getting-started/src/app/product-details/product-details.component.1.ts +++ b/aio/content/examples/getting-started/src/app/product-details/product-details.component.1.ts @@ -23,8 +23,11 @@ export class ProductDetailsComponent implements OnInit { // #enddocregion props-methods // #docregion get-product ngOnInit() { - this.route.paramMap.subscribe(params => { - this.product = products[+params.get('productId')]; + // First get the product id from the current route. + const productIdFromRoute = this.route.snapshot.paramMap.get('productId'); + // Find the product that correspond with the id provided in route. + this.product = products.find(product => { + return product.id === Number(productIdFromRoute); }); // #docregion product-prop } diff --git a/aio/content/examples/getting-started/src/app/product-details/product-details.component.ts b/aio/content/examples/getting-started/src/app/product-details/product-details.component.ts index f3731e7e65..8460b7cb9b 100644 --- a/aio/content/examples/getting-started/src/app/product-details/product-details.component.ts +++ b/aio/content/examples/getting-started/src/app/product-details/product-details.component.ts @@ -30,8 +30,11 @@ export class ProductDetailsComponent implements OnInit { // #docregion get-product ngOnInit() { // #enddocregion props-methods - this.route.paramMap.subscribe(params => { - this.product = products[+params.get('productId')]; + // First get the product id from the current route. + const productIdFromRoute = this.route.snapshot.paramMap.get('productId'); + // Find the product that correspond with the id provided in route. + this.product = products.find(product => { + return product.id === Number(productIdFromRoute); }); // #docregion props-methods } diff --git a/aio/content/examples/getting-started/src/app/product-list/product-list.component.html b/aio/content/examples/getting-started/src/app/product-list/product-list.component.html index f1b86df848..3bff6c54fc 100644 --- a/aio/content/examples/getting-started/src/app/product-list/product-list.component.html +++ b/aio/content/examples/getting-started/src/app/product-list/product-list.component.html @@ -1,10 +1,10 @@