Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 在路由-角度内将数据从子级发送到父级_Angular_Typescript - Fatal编程技术网

Angular 在路由-角度内将数据从子级发送到父级

Angular 在路由-角度内将数据从子级发送到父级,angular,typescript,Angular,Typescript,我有两个组件:ProcessComponent和ClientTypeComponent绑定到路由 const routes: Routes = [ { {path: 'login', component: LoginComponent}, {path: 'home', component: HomeComponent, canActivate: [AuthGuard]}, { path

我有两个组件:ProcessComponent和ClientTypeComponent绑定到路由

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]}
                ]
            }

];
如何将简单的布尔值从/process/client type发送到/process

我既不能使用数据绑定也不能使用EventEmitter,因为我不使用嵌套组件,而是使用嵌套路由


可能有办法,但我找不到任何答案。

您应该使用服务来获取价值。在路由到
'client-type'
之前,将值存储在服务中。在Ngonit中获取
ClientTypeComponent

的值试试这个,我认为它是

的副本。ClientTypeComponent中的值可以更改,所以它不能是唯一的。这不是一个副本,但也许我可以使用它。将一个事件发送到一个服务,该服务将另一个事件发送到我的父组件是的,您可以使用它,并且我认为这是将数据从一个组件传递到另一个组件的正确方式(从angular文档中):
this.router.navigate(['/heros',{id:heroId foo:'foo')或如前所述,使用服务