Binding Properties of an Object to Its Own Properties Edit Page
Problem
You want to base the value of one property on the value of another property.
Solution
Use one of the computed property macros like Ember.computed.alias
or Ember.computed.equal
1 2 3 4 5 6 |
App.Person = Ember.Object.extend({ firstName : null, lastName : null, surname : Ember.computed.alias("lastName"), eligibleForRetirement: Ember.computed.get("age", 65) }); |
Discussion
Ember.js includes a number of macros that will help create properties whose values are based
on the values of other properties, correctly connecting them with bindings so they remain
updated when values change. These all are stored on the Ember.computed
object
and documented in the API documentation