Ember.js: How can I use the controllers / views of another route

advertisements

I have complete contact edit dialog. I now would like to create the matching new contact dialog with the least necessary effort. The new dialog is identical, appart from the model initialisation.

I have the following New route:

App.ContactNewRoute = App.BaseEntityRoute.extend({
        init: function () {
            this._super();
            this.keyName = "contact_id";
            this.controllerRoute = "contact.new";
            this.datasource = App.contactDataSource.getNewContact;
        }
});

How can I tell ember that it should use the ContactEditController and ContactEditView for this route?


If you want to reuse the class, why not try something like this?

App.ContactNewController = App.ContactEditController.extend();

App.ContactNewView = App.ContactEditView.extend();

Ember now finds the classes based on its naming schema and everything should be fine. But why do you actually need that? You are basically mirroring all parts of an route in a new route with a new name, but all other components (controller, view) stay the same?