Angular4 Set Var if Route == 'settings'

211 views Asked by At

I got a problem, I have no idea how to set a variable in a component to true when the route path hits 'settings'

This is my Route:

{
    path: '', component: FrameDefaultComponent,
    children: [
        {path: 'home', component: SiteHomeComponent},
        {path: 'home/:page', component: SiteHomeComponent},
        {
            path: 'user/settings', component: SiteUserSettingsComponent,
            children: [
                {path: '', component: SiteUserProfileHomeComponent},
                {path: 'home', component: SiteUserProfileHomeComponent},
                {path: 'about', component: SiteUserProfileAboutComponent}
            ]
        },
        {
            path: 'user/:id', component: SiteUserProfileComponent,
            children: [
                {path: '', redirectTo: 'home', pathMatch: 'full'},
                {path: 'home', component: SiteUserProfileHomeComponent},
                {path: 'about', component: SiteUserProfileAboutComponent}
            ]
        }
    ]
}

Now I have a component named coverComponent.ts and I want to set a variable to true, when I am inside the 'user/settings' path.

The problem is when I do it with this.router.url === 'user/settings', it doesn't work, because the first path inside the user/settings route redirects to home. Then is the home user/settings/home... And I got sub router-outlets with other routes, like 'about'.

How can I set the var to true, for the whole user/settings page?

0

There are 0 answers