It's entirely possible that I'm not quite understanding the order of instantiation of controllers when a route is entered, but I'm attempting to get currentPath
in beforeModel
in my ApplicationRoute and struggling. The odd thing is when I log the route, I can see a property called controller
in it...
beforeModel: function(transition) {
console.log(this);
console.log(this.controller); // undefined
console.log(this.get('controller')); // undefined
// this too
console.log(this.controllerFor('application'));
console.log(this.controllerFor('application').currentPath); // undefined
console.log(this.controllerFor("application").get("currentPath")); // undefined
},
But this.controller
is undefined. As you can see in the log output, currentPath is indeed set on that property, and that's what I want!
I noted that controller
clearly isn't defined until after the router has instantiated the controller. So the documentation is somewhat clear in that in willTransition
, this.controller
is defined.
The controller property seems to get defined in setup
so I'm super confused as to how I can see it in beforeModel
. How can I get currentPath
in beforeModel
in ApplicationRoute
?