Search⌘ K
AI Features

Setting up Dynamic Routes

Explore how to set up dynamic routes in Ember.js within nested routing structures. Learn to define URLs that adapt to IDs and categories, pass models between routes, and load data dynamically for editing products and displaying category-specific content.

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 edit route: To edit products, we need to load them first. Every product has a unique ID. We need to load the data model to the edit route based on that ID’. Here, we need the URL to be http://localhost:4200/admin/edit/<id>.
  • The category route: 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 the category route dynamic to load different categories with different data models. Here, we want
...