February 2016
Beginner to intermediate
308 pages
5h 46m
English
In this recipe, we'll take a look at computed properties and how they can be used to display data, even if that data changes as the application is running.
Let's create a new Ember.Object and add a computed property to it:
description computed property. This property will reflect the status of the isOn and color properties:const Light = Ember.Object.extend({
isOn: false,
color: 'yellow',
description: Ember.computed('isOn','color',function() {
return 'The ' + this.get('color') + ' light is set to ' + this.get('isOn');
})
});Light object and get the computed property description:const bulb = Light.create(); bulb.get('description'); //The yellow light ...Read now
Unlock full access