So I’m trying to get the current route name (to make sure it doesn’t equal a certain route to show this section of the layout)… Right now, I’m using something like this:
This doesn’t seem to update quick enough when I navigate to a different page. I’m on contracts.index and then I click a link that should lead to contracts.contract.index which it does, but the routing service doesn’t seem to update quick enough… it still says I’m on contracts.index and then if I do a simple page refresh, THEN it shows contracts.contract.index. Is there another way around this?
I do a console.log(this.get('routing')) and it SHOWS that the currentRouteName property DOES equal contracts.contract.index, but whenever I do a .get('currentRouteName') it still says contracts.index which makes no sense… when i do that console log it tells me something else until I perform the .get() on the property.
I put this in the setupController method and got it working, but all it returns is contracts as the routeName no matter what sub route I’m in of contracts… that’s not exactly what I need.
you’re right, it wasn’t there in the init hook. Your subroutes would need to implement something similar if you need their names. I simple mixins to help with this.
just to keep up to date today is no longer used this.get(‘routing’).get(‘currentRouteName’)
the correct one to use today is this.get(‘router’).get(‘currentRouteName’)