0
votes

In the official Ember documentation is a section describing automatically generated controllers, once the model in a route has been set:

http://emberjs.com/guides/routing/generated-objects/#toc_generated-controllers

I wonder what would be the explicit code pendant to this process? In the doc it says "If you did not define it, one will be generated for you." and I assume, this does not happen in form of some auto-generated code, but in memory only.

Can someone show how the simplest version of an

  • ObjectController
  • ArrayController
  • Controller

would look like if you generated them in Ember-CLI by hand?

1

1 Answers

2
votes

If you generated ObjectController, ArrayController and Controller by hand using Ember-CLI they would each be empty, as follows:

ObjectController:

import Ember from 'ember';

export default Ember.ObjectController.extend({

});

ArrayController: import Ember from 'ember';

export default Ember.ArrayController.extend({

});

Controller: import Ember from 'ember';

export default Ember.Controller.extend({

});

You can see the that these are the blueprints Ember-CLI uses to generate the controllers by checking the Ember-CLI source here.

You'll notice that the changeset I've linked to is removing the blueprints that generate controllers for the aforementioned controllers. I've done this to emphasize that Ember eventually be removing support for controllers following the 2.0 release. See the section entitled Routable Components in The Road to Ember 2.0 RFC.