Computed Properties

Computed properties are a huge part of managing model properties for your templates and components. Ember.computed is a method that takes the values of scoped properties and returns a value when the method ends. Invoking the following, for example, would give you a computed property with the object’s first_name property changed to lowercase:

Ember.computed('first_name', function(){
  return this.get('first_name').toLowerCase();
});

In this example, Ember.computed is acting as an event listener for changes to first_name. You do not have to change the set method to trigger an event, you do not have to add an event listener, and you do not have to change the first_name property. All you do is create a new property ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.