How can I find the active route?

I have a VM that defines routes and displays a menu. One of the routes is configured as nav: false. Because of this, it will not appear in the router.navigation routes – so no way to access isActive.

However, when this route is active, I don’t want the menu displayed. In this blog post by Dwayne Charrington, he indicates that activate accepts a second parameter – navigationInstruction. However, that always comes in undefined for me – so I’m guessing that was an old blog post and that that parameter is no longer passed.

So, is there a way for me to access the active route?

Have you tried using this.router.currentInstruction? It should expose everything necessary for the currently active route

I have used it like this, setting up the route, and passing the settings parameter.

{
        route: ['syllabus-pp'],
        name: 'syllabus-pp',
        moduleId: PLATFORM.moduleName('./pages/training/syllabus/syllabus-pp'),
        nav: false,
        title: 'Syllabus - Private Pilot',
        auth: true,
        setting: {id: 'syllabus-pp'}
    }
    activate(params: any, setting: any)
    {
    }
1 Like