Searching Products in the category Route
Explore how to implement a search bar in an Ember.js category route by creating a controller with tracked properties and actions. Understand how to filter products dynamically using regular expressions, reset filters when routes change, and conditionally display filtered or all products based on user input.
We'll cover the following...
We'll cover the following...
Now, let’s add a search bar in the category/index.hbs template to receive the filter value.
Adding a search bar
We need to add a search bar and set up the category.index controller to search the product in the category route. Let’s add the search bar in the app/templates/category/index.hbs template:
- Line 3–15: We add a
divof12-coland wrap our search bar in adivof9-col.- Line 8: We insert an
inputfield with the searchid. - Line 11: We create a button with the
searchclick event.
- Line 8: We insert an
Setting up the category/index controller
Next, we need to ...