Using the ideas from @ maharaja-santhir's answer, you might consider setting the routeName property on the target controller for use, for example, in the target template. Thus, there is no need to define logic in several places and, therefore, to reuse the code. Here is an example of how to do this:
// app/routes/application.js export default Ember.Route.extend({ ... actions: { willTransition(transition) { let targetController = this.controllerFor(transition.targetName); set(targetController, 'currentRouteName', transition.targetName); return true; } } });
Defining this willTransition action in the application route allows you to distribute the current route name anywhere in the application. Note that the target controller will retain the currentRouteName property parameter even after going to another route. This requires manual cleaning if necessary, but it may be acceptable depending on your implementation and use.
source share