Search⌘ K
AI Features

Handling Actions with Controllers

Explore how to manage user interactions in Ember.js by defining actions within controllers and using the on HTML modifier to handle events like button clicks. Understand how to generate routes and controllers, link them, and trigger JavaScript methods from templates to create responsive web applications.

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 ...