Model is a class that extends the functionality of the Ember Data which specifies relationships with other objects. In Emberjs, every route has an associated model and when a user refreshes the page, the contents of page should be represented by a model.
The model can be created by using the following command −
ember generate model model_name
It creates the file structure under app/models/model_name.js as shown below −
import DS from 'ember-data'; export default DS.Model.extend ({ });
Defining Attributes
The DS.attr is used to specify attributes for a model. This also takes an optional second parameter as hash.
For instance −
import DS from 'ember-data'; export default DS.Model.extend ({ bookName: DS.attr(), authorName: DS.attr() });
Previous Page:-Click Here