+1 vote
in JavaScript by
EmberJS –Classes and Instances

1 Answer

0 votes
by
Class is a template or blue print, that has a collection of variables and functions, where as

instances are related to the object of that class. Creating and extending the Ember class on

Ember.Object is the main property of the Ember object model.

Defining Classes

You can create new Ember class by using the Ember.Object's extend() method:

const Demo = Ember.Object.extend({

 //code here

});

The above code creates new Ember class called "Demo" which inherits the properties from

initializers, computed properties, etc. After creating the class, you need to create instance of

it by using the create() method as shown below:

const state = Demo.create();

Using the above instance "state", access the properties by using the set and get accessor

methods.

console.log(state.get('stateOn'));

You can change the "stateon" property by using the set method as shown below:

state.set('stateOn', true);
...