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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.