0
votes

When I try to initialize my ember App with an ArrayController I got an issue but only when ember-data is added to the project. Here's a quick example at http://jsfiddle.net/ySmZr/2/

App = Em.Application.create();
App.customerController = Em.ArrayController.create({});
App.initialize();​

return the following error :

Uncaught TypeError: Cannot call method 'get' of undefined  (ember-data-latest.js:3693)

Without ember-data I got no error. I looked everywhere and I just can't find why ember is acting like this... Any idead ? Thanks !

2

2 Answers

3
votes

When calling initialize() you must set Router stuff. See this

From documentation:

You can provide a subclass of Ember.Router as the Router property of your application. An instance of this Router class will be instantiated and route detection will be enabled when the application's initialize method is called. The Router instance will be available as the router property of the application

There are 2 solutions:

  • call initialize(), provide Application with router and use its capabilities
  • don't use initialize()
2
votes

If you are using Ember Data, you have to create a class of the controller (capitalized) and then extend the method. So it should look like:

App.CustomerController = Em.ArrayController.extend({});

Then, you just call an instance of the controller whenever you need to use it.