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!
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
In an Ember Engines RFC discussion, bcardarella, asks, "What's the difference between an Ember Engine and Ember Addon"? The discussion continues where ef4 says, "The only thing addons can't do is add routes to the router map.", (I think he means in an automatically merged way), however an alternative and example is given in the RFC thread:
https://github.com/emberjs/rfcs/pull/10#issuecomment-60504581 https://github.com/dockyard/ember-admin#usage
Thus you can use the workaround approach suggested by bcardarella. Or, you can try Ember Engines (which is also delivered in an Addon package).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With