What’s the best way to capture the current state of an Ember app, that is represented by the URL, and is compatible with
My first thought was to store
currentRouteName along with the model using
// in some-route.js var currentRouteName = this.controllerFor('application').get('currentRouteName') var model = this.modelFor(currentRouteName) … // somewhere else this.transitionTo(currentRouteName, model)
The downsides of this approach are that it will not work with nested resources (
modelFor(routeName) only returns a single model), and it will require some additional work for use with query params.
Another approach might be to simply grab the path from
var currentPath = location.href.slice(location.href.indexOf(location.pathname)) … // somewhere else this.transitionTo(currentPath)
The downsides are that it may not work if the Ember app does not reside at the root url, and that it may run model hooks unnecessarily.
It feels like there should be a better way to do this. Am I missing something?