Creating and extending classes is a major feature of the Ember object model. In this recipe, we'll take a look at how creating and extending objects works.
Let's begin by creating a very simple
Ember
class usingextend()
:const Light = Ember.Object.extend({ isOn: false });
This defines a new
Light
class with a property calledisOn
.Light
inherits properties and behavior from the Ember object, such as initializers, mixins, and computed properties.Tip
Ember Twiddle tip
At any point of time, you might need to test out small snippets of the Ember code. An easy way to do this is to use a website called Ember Twiddle. From this website, you can create an Ember application and run it in the browser as if you were using the Ember CLI. You can even save and share it. It has similar tools such as JSFiddle but only for Ember. Check it out at http://ember-twiddle.com.
Once you have defined a class, you'll need to be able to create an instance of it. You...