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
This commit is contained in:
George Kalpakas 2021-01-06 23:05:46 +02:00 committed by atscott
parent 1d78d4d774
commit d08828339b
2 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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
}