Search code examples
ember.jsember-router

How to get next route after the current route deactivate.?


I have some code that uses route 'deactivate' method as follows.

 deactivate: function() {
        this._super();
        //some code here

    }

Is there a way to identify where is user trying to go(route of URL) after this route deactivates?


Solution

  • I would encourage you to use willTransition actions method hook for this purpose since that will be called before deactivate hook method.

    transition.targetName will provide the target route.

    actions: {        
            willTransition(transition) {
                this._super(...arguments);
                console.log('willTransition user ', transition.targetName);
            }
        }