-
Book Overview & Buying
-
Table Of Contents
Angular Projects - Fourth Edition
By :
The application will display product details on a separate page that opens when the user selects a product from the list. We will use routing to query the Fake Store API by product ID. The page will display the name, category, and price of the product. Users will be able to generate a QR code on the page for later use.
We will begin by adding an appropriate method in the products service and then create the product details page:
products.ts file and add the following method:
getSingle(id: number) {
return this.http.get<Product>(
'https://fakestoreapi.com/products/' + id
);
}
The preceding method will query the Fake Store API for a product with a specific ID and return full details of the current product.
ng generate resolver product
We will use a resolver to fetch the product details before showing the respective component.
Resolvers provide good UX when you do not want to load...