Ember Data: model.get ('modelName') is undefined, but model._internalModel works

I am using Ember Data 2.2.0 and Ember 2.2.1. After retrieving the model from the data store, I would like to get the model type name as a string.

According to the API docs, DS.Model defines a modelName property that looks the way I want. However, I found that model.modelNameboth model.get('modelName')are undefined after retrieving modelfrom the store using findRecord.

On the other hand, model._internalModel.modelNamereturns the bottom aligned name of the model as expected.

What's going on here?

+4
source share
1 answer

. , modelName DS.Store#modelFor, Ember.Route#modelFor.

DS.Store#modelFor " . , (, find, createRecord ..)". , DS.Model, . _internalModel DS.Model, , .

, model.constructor.modelName.

+9

Source: https://habr.com/ru/post/1624864/


All Articles