mercredi 12 juillet 2017

Ember: get target url from afterModel

I have two paths pointing to the same route:

this.route('items', { path: ':fruitName/rotten' });
this.route('items', { path: ':fruitName' });

I am trying to get the current URL from within the afterModel hook of the /items/fruitName route. If I use this.get('router.url'), it will give me the previous URL before the transition. I need to detect if the target has 'rotten' at the end of the path.

I found that transition.intent.url has the path as a string, but only when its manually entered into the browser. If I click a link to transtion, transition.intent.url is undefined.

How can I determine if the transition URL is /items/fruitName/ or /items/FruitName/rotten?




Aucun commentaire:

Enregistrer un commentaire