O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining component actions

We mentioned that components define classes that act as their controllers that are isolated from the rest of the application. For example, an application controller cannot define a component class as a dependency in its needs property. However, since they are considered as controllers, they can define handlers to action expressions defined in their corresponding templates in an actions object property. For example, let's define a message box component that can be used in any application that needs to implement the chat functionality:

{{! template }}] <form {{action 'save' on='submit'}}> {{input value=message}} </form> // component classApp.MessageBoxComponent = Ember.Component.extend({ message: '', classNames: ['message-box'], ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required