How does one access the instance of the new Ember router? The API docs seem to be refer to the old router or are incorrect: http://emberjs.com/api/classes/Ember.Router.html
RouterV2 is not easily accessed via a global constant, making it more difficult to do things the 'wrong' way. The main thing to keep in mind is that you should not be accessing the router (or anything else) via a global variable. Doing so is a generally bad practice, leading to code that is very hard to test. Unfortunately with the old router it was pretty easy to do something like App.router.transitionTo('whatever')
- you can find examples of that all over the place, but it's not a good idea.
Instead of working with a global reference, ember injects local references to the router in just those places where it is needed.
router = this.get('target')
this.get('controller').send('search', term)
{{action}}
or {{#linkTo}}
helpers to send events (via the controller) or transition to another url.For more detail, see the notes on this commit: https://github.com/emberjs/ember.js/commit/5becdc4467573f80a5c5dbb51d97c6b9239714a8
** Update **
I put together a lightning talk on with more detail on the new router for the January EmberNYC meetup - slides are here: How I learned to stop worrying and love the router
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