Setting up Dynamic Routes
Learn to make dynamic routes.
We'll cover the following...
We'll cover the following...
Dynamic routes are used to load dynamic data into the routes. They can load different data models on the same route.
What do we want to achieve?
We need three dynamic routes in our application:
- The
editroute: To edit products, we need to load them first. Every product has a unique ID. We need to load the data model to theeditroute based on that ID’. Here, we need the URL to behttp://localhost:4200/admin/edit/<id>. - The
categoryroute: We need to show products by category to the users. There can be several categories in our application, and we can’t make a separate route for each category. We need to make thecategoryroute dynamic to load different categories with different data models. Here, we want