My router.js
is like this:
// router.js
this.route('cards', function() {
this.route('all');
this.route('card', {path: '/:card_id'}, function() {
this.route('edit');
});
this.route('new');
});
Now, suppose, I'm inside this link: /cards/1
. When I refresh this page, I go to the route /cards/all
.
I'm redirecting to /cards/all
from /cards
:
// cards.js
beforeModel() {
this.transitionTo('cards.all');
}
Why am I getting redirected to /cards/all
when I refresh in /cards/1
?
Repo link: https://github.com/ghoshnirmalya/hub-client.
You are transitioned to /cards/all
because the route /cards/:card_id
is nested into /cards
route so when you enter the /cards/:card_id
route the order of execution is:
cards
route (beforeModel, model, ...)cards/:id
route (beforeModel, model, ...)But in cards route beforeModel you are transitioning to cards.all
, that's why the redirect.