How do I access the service variable in my routing file?
I created a UserService
with a variable named user
and I need to use that variable in my routing file.
Here is the approach I tried, but it didn't work:
In the routing file, I attempted:
const steps = this.userService.user.onboardingStatus; //throws an error ---> *cannot find name userService*
const routes: Routes = [
{
path: 'welcome',
component: WelcomeComponent,
},
{
path: 'product-selection',
component: ProductSelectionComponent,
canActivate: [ClientRoutesGuard],
data: {
isStepAccessible: steps.['welcome'].status, //will return true or false
},
},
]
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ClientRoutingModule {
constructor(public userService: UserService) {}
}
Thank you for your help!