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

Writing template bindings

In the Writing bound and unbound expressions section, we mentioned that the Ember.js Handlers library enables a variable defined in an expression to subscribe and, hence, updates to the changes of the bound context. The library also enables us to bind these variables to HTML element attributes, including classes using the {{bind-attr .. }} helper. In the following example, we define a link whose href property is bound to the provided user profile as:

    <a {{bind-attr href="profile.link"}}>User Profile</a>

By now we all know how the profile context will be provided by the route handler's model hook. For example, if this is the application's template, the corresponding route handler will provide the context as:

 App.ApplicationRoute ...

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