DS.Model.modelName

modelNameStringstatic

Defined in addon/-private/system/model/model.js:985

Represents the model's class name as a string. This can be used to look up the model through DS.Store's modelFor method.

modelName is generated for you by Ember Data. It will be a lowercased, dasherized string. For example:

store.modelFor('post').modelName; // 'post'
store.modelFor('blog-post').modelName; // 'blog-post'

The most common place you'll want to access modelName is in your serializer's payloadKeyFromModelName method. For example, to change payload keys to underscore (instead of dasherized), you might use the following code:

export default var PostSerializer = DS.RESTSerializer.extend({
  payloadKeyFromModelName: function(modelName) {
    return Ember.String.underscore(modelName);
  }
});
doc_EmberJs
2016-11-30 16:50:17
Comments
Leave a Comment

Please login to continue.