Azoulay Jason
Azoulay Jason

Reputation: 2989

Send data from child to parent within routing - Angular

I have 2 components: ProcessComponent & ClientTypeComponent binded to routes.

const routes: Routes = [
    {
            {path: 'login', component: LoginComponent},
            {path: 'home', component: HomeComponent, canActivate: [AuthGuard]},
            {
                path: 'process', component: ProcessComponent, canActivate: [AuthGuard], children: [
                    {path: 'client-type', component: ClientTypeComponent, canActivate: [AuthGuard]}
                ]
            }

];

How can I just send a simple boolean value from /process/client-type to /process

I can't use neither data-binding or EventEmitter since I don't use nested components but nested routes.

There is probably a way but I can't find any answers.

Upvotes: 2

Views: 49

Answers (2)

chirag sorathiya
chirag sorathiya

Reputation: 1243

try this i think it's duplicate of How do I pass data to Angular routed components?

Upvotes: 1

Basavaraj Bhusani
Basavaraj Bhusani

Reputation: 5673

You should use service to get the value. You store the value in service before routing to 'client-type'. Get the value in ngOninit of ClientTypeComponent

Upvotes: 0

Related Questions