I use Ember-CLI to build my ember application, but I don't want to use Ember Data.
By default, when you type this command: ember generate model Person, ember-cli would create a js file under models named "person.js", and it will be a DS.extend(...). I don't want that, I want a plain ember object. So... I delete the person.js and create manually a js file named models.js (that's where I'm going to declare all my ember objects).
Here's what I have in models.js:
import Ember from "ember";
App.Person = Ember.Object.extend({
helloWorld: function() {
alert("Hi, my name is " + this.get('name'));
}
});
I have checked that "App" is available (there's a var named App declared in app.js -- generated by EmberCLI -- and it is exported).
So... now... I want to use it from my Route. I have something like this (in a js file named person.js under "routes"):
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return App.Person.create({
name: "Tom Dale"
});
}
});
Well... it doesn't work. The console says: Error while processing route: person.index App is not defined ReferenceError: App is not defined.
Ok... I checked the generated js file (myproject.js): I found this:
define('infoleccion2015/tests/models/models.jshint', function () {
'use strict';
module('JSHint - models');
test('models/models.js should pass jshint', function() {
ok(false, 'models/models.js should pass jshint.\nmodels/models.js: line 3, col 1, \'App\' is not defined.\n\n1 error');
});
});
Turns out that "App" is not recognized anywhere (not even from models.js).
I'm new to EmberCLI. Can someone tell me what to do here? It's a strict requirement that we can't use Ember-Data.
Thanks!
Aucun commentaire:
Enregistrer un commentaire