From d08828339bd7fb5da23da4f4598e6b4f60db4836 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 6 Jan 2021 23:05:46 +0200 Subject: [PATCH] docs: refactor code in `get-product` docregion of `getting-started` docs example (#40197) This commit slightly refactors the code in the `get-product` docregion of the `getting-started` docs example to make it easier to follow. PR Close #40197 --- .../app/product-details/product-details.component.1.ts | 8 ++++---- .../src/app/product-details/product-details.component.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) 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 }