In Ember.js, when you click on a link inside your app, you can conditionally prevent transitioning to the target page by using transition.abort()
, for example:
afterModel: function(model, transition) {
if (!model.user.get('facebookAuthenticated')) {
if (confirm("You have to log in with facebook. Continue?")) {
this.controller.send('facebookLogin');
}
else {
transition.abort();
}
}
}
This will cancel the transition and you will stay on the current page.
But what if you're landing in the app into this route, for example by following an external URL ? Then the default behaviour is to go ahead and execute transition.abort()
, which leaves you on a blank page. Not acceptable at all.
Is there a way to detect if the user is landing on this route, so that the app can redirect or something?
Aucun commentaire:
Enregistrer un commentaire