Setting up the category Route
Learn to set up the category route for our e-commerce application.
Let’s design the category
route to render all the products by category using the category.hbs
template. To display the products, we import the products in the app/routes/category.js
file. Then, we add the return statement for the products in the model:
// app/routes/category.jsimport Route from '@ember/routing/route';import { products } from '../data/products';export default class CategoryRoute extends Route {model(params){return products;}}
In line 7 of the code above, we return the products from our route handler. Next, we render these products in the category.hbs
...