I created a model:
ember g model test name:string
When i try to instanciate it, it doesnt work:
//app/routes/example.js
model(params) {
return Ember.test.create({
name: params.value });
},
In the console i can see: test Cannot read property ‘create’ of undefined TypeError: Cannot read property ‘create’ of undefined
Can you explain why it doesnt work?
While creating model from ember-cli make changes in the file so created as below:
say it is test.js (model)
import Ember from 'ember';
export default Ember.Object.extend({
});
and to import and instantiate the above in some other component or model
write import statement on top of the file
say testme.js (model or component)
import test from './../test'; //make path as per ur requirement
export default Ember.Object.extend({
test: test.create(),
});