home
  • Blog
1.12
  • Getting Started
  • Concepts
  • The Object Model
  • Application
  • Templates
  • Routing
  • Components
  • Controllers
  • Models
  • Views
  • Enumerables
  • Testing
  • Configuring Ember.js
  • Ember Inspector
  • Cookbook
    • Introduction
    • Contributing
    • User Interface and Interaction
    • Event Handling & Data Binding
      • Introduction
      • Binding Properties of an Object to Its Own Properties
    • Helpers & Components
    • Working with Objects
  • Understanding Ember.js
  • Contributing to Ember.js
Old Guides - You are viewing the guides for Ember v1.12.0.
Go to v5.0.0

Binding Properties of an Object to Its Own Properties

Edit pencil

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.gte

app/models/person.js
export default Ember.Object.extend({
    firstName : null,
    lastName : null,
    surname : Ember.computed.alias("lastName"),
    eligibleForRetirement: Ember.computed.gte("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

left arrow
Introduction
We've finished covering Event Handling & Data Binding. Next up: Helpers & Components - Introduction
right arrow
On this page

  • Problem
  • Solution
  • Discussion
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2023 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue