Is there a way to have a conditional redirect in the Ember.js Router, without breaking internal consistency of the router?
相关问题
- Inserting a translation into a placeholder with Em
- Can't find module on migrating ember-cli app t
- How to get the value of a checkbox of a template i
- ember component based on model type
- ember Error: Compile Error: is not a helper
相关文章
- How to use autofocus with ember.js templates?
- Including dependencies with ember-cli
- Pass a reference of the clicked DOM element to the
- Ember upgrade breaks one test, and only in Safari
- ember testing Error Adapter operation failed
- Ember : addObject/ pushObject is not a function
- Ember: use controller data in route or how to fetc
- Setting tagName on application template in ember j
What you could do (as of today), is something like that:
Do not miss the
Ember.run.next
as while you are inenter
, the state transition is always pending, so you have to transition after that.We use it as shown for authent, but you could imagine using it for whatever condition you have to...
Depending on what you're trying to do, you may be looking for conditional transitions. This is covered in another stackoverflow question, the TLDR of which is to check this fiddle.
The new router now includes a
hook which you could over-ride to include conditional logic while transitioning to a route. The beforeModel hook will be called before the
hook is called and it gets passed a
object. You can decide if you want to redirect to another route using
or you could abort the transition if you don't want to redirect by calling