Search⌘ K

Defining the Model for Our Application

Learn to define data models in Ember.

The model class defines the behavior and properties of the data presented to the user. We need a product model for our e-commerce application that will define the properties of that product. Let’s create a product model.

Generating a model

We need to create a new JavaScript file in the app/models directory. We can either create it manually or use the following command:

ember g model product

This command generates a boilerplate for our model named product.js in app/models. Let’s open the product.js ...