Skip to content

Instantly share code, notes, and snippets.

@brenna
Last active January 5, 2016 19:39
Show Gist options
  • Save brenna/238be391fd62cc1023d1 to your computer and use it in GitHub Desktop.
Save brenna/238be391fd62cc1023d1 to your computer and use it in GitHub Desktop.
Ember router service
import Ember from 'ember';
export default Ember.Component.extend({
router: Ember.inject.service()
// ...component stuff that uses transitionTo
});
//polyfill an injectable router with a custom service
import Ember from 'ember';
export default Ember.Service.extend({
emberRouter: null,
stealRouter: Ember.on('init', function() {
const router = this.container.lookup('router:main');
this.set('emberRouter', router);
}),
transitionTo(...args) {
this.get('emberRouter').transitionTo(...args);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment