Handling Actions with Controllers
Learn to handle actions using controllers.
We'll cover the following
Defining an action
We use the on
HTML modifier to attach an event handler to an HTML tag. HTML modifiers are syntactic sugar provided by Ember for adding an event and removing event handlers. Let’s create a simple click event handler in our e-commerce application. Use the command below to create a new route named practice
:
ember g route practice
Let’s create a button in practice.hbs
. We want to create an alert
that notifies the users that the button has been clicked. Let’s open practice.hbs
below in our code widget and add the required code:
Get hands-on with 1400+ tech skills courses.