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:
parent
1d78d4d774
commit
d08828339b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue