Built-in Helper Functions
Learn about built-in helper functions in Ember and how to use them.
We'll cover the following...
Overview
Sometimes, we need to perform tasks that have to be repeated throughout an application, such as computing the square of a number or concatenating strings. Ember provides some built-in helpers that are very useful for performing such tasks. The following are some of the built-in helpers provided by Ember:
-
The
{{on}}
helper is used to register an event listener for an element that’s within the scope of the current template. It can also be used to register an event listener for an element or a genericEventTarget
outside the template’s control—for example,document
orwindow
. The following is a basic example of how the{{on}}
helper can be used:{{on "click" (addFunction 2 4)}}
The example illustrates that when the ...