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

Creating property bindings

Ember.js provides support for both one- and two-way bindings. A binding is a link between two properties of the same or different objects, such that they are always in sync. This means that an update to one of the properties results in the other property being updated to the new value. Bindings are defined in the following signature:

property: Ember.computed.alias('otherProperty'),

In this case, the two properties property and otherProperty always stay in sync. Here's an example:

var author = Em.Object.create({ name: 'J. K. Rowling' }); var book = Em.Object.create({ name: 'Harry Potter', authorName: Ember.computed.alias('author.name') }); console.log(book.get('authorName')); // J. K. Rowling author.set('name', 'Joanne Rowling'); ...

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