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 549da4f26b..d598b3d389 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 @@ -24,11 +24,11 @@ export class ProductDetailsComponent implements OnInit { // #docregion get-product ngOnInit() { // First get the product id from the current route. - const productIdFromRoute = this.route.snapshot.paramMap.get('productId'); + const routeParams = this.route.snapshot.paramMap; + const productIdFromRoute = Number(routeParams.get('productId')); + // Find the product that correspond with the id provided in route. - this.product = products.find(product => { - return product.id === Number(productIdFromRoute); - }); + this.product = products.find(product => product.id === productIdFromRoute); } // #enddocregion get-product // #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 73a7339503..1c5056a527 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,11 +30,11 @@ export class ProductDetailsComponent implements OnInit { ngOnInit() { // #enddocregion props-methods // First get the product id from the current route. - const productIdFromRoute = this.route.snapshot.paramMap.get('productId'); + const routeParams = this.route.snapshot.paramMap; + const productIdFromRoute = Number(routeParams.get('productId')); + // Find the product that correspond with the id provided in route. - this.product = products.find(product => { - return product.id === Number(productIdFromRoute); - }); + this.product = products.find(product => product.id === productIdFromRoute); // #docregion props-methods }