ember.jsember-addon

Add route to Ember Addon


i'm developing ember addon and i need to share one route between all applications that use this addon but i don't know how to achieve that or if it's even possible. Already i've add routes in addon, but application that counsume addon, doesn't see this. Any suggestions? Thanks!


Solution

  • Yes it is possible. What you put in your addon's app directory will be merged with consuming applications' app directory. (Resource) Put your routes into the correct directories.

    On the other hand, you need to add your routes to the router mapping. You can use instance-initializers for this purpose. Also doesn't forget to put your instance-initializers in your app directory. All you need to do in your initializer function is calling Router.map(...) The code will be something like that:

    import Router from '../router';
    
    function initialize(){
      Router.map(function() {
        this.route('yourroute');
      });
    }
    

    ps: code updated