Inject Route actions from within Ember Addon

Is there any better way for handling this instead of dirty workaround using ApplicationRoute._actions

You can use reopen.

Add this initializer to your ember-cli addon project:


import Ember from 'ember';
export default {
    name: 'add-action-to-application-route',
    initialize: function(container, app){{
            var applicationRoute = container.lookup('route:application');
            if (applicationRoute && typeof applicationRoute.reopen === 'function'){
                    actions: {
                        doMore: function(){
                            //doing More

Existing actions won’t be overridden.

JS Bin Demo

1 Like

Holly smokes! This indeed did the trick.

Thank you so much @ramybenaroya

Is there any particular reason you need to

Without the The lookup method returned undefined.