Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.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_Routing_Angular Routing - Fatal编程技术网

Angular 角度传感器中的父子路由

Angular 角度传感器中的父子路由,angular,routing,angular-routing,Angular,Routing,Angular Routing,当我在angular中执行路由时,我得到了一个类似error:无法匹配任何路由的错误。URL段:“example2/child1”这里我在app.module.ts { path:"for", component: ForComponent }, { path:"example1", component: Example1Component }, { path:"example2",component: Example2Component , chil

当我在angular中执行路由时,我得到了一个类似
error:无法匹配任何路由的错误。URL段:“example2/child1”
这里我在
app.module.ts

{ path:"for", component: ForComponent },
      { path:"example1", component: Example1Component },
      { path:"example2",component: Example2Component ,
          children: [          
          { path:"child1",component:Child1Component },
          { path:"child2",component:Child2Component },
          { path:"child3",component:Child3Component }
          ]
      }      
在父组件中,我设置动态链接以导航子组件

<ul>
     <li *ngFor="let item of coutry">
         <a href="" routerLink="{{item.name}}" >{{item.name}}</a>
     </li>
</ul>

那我该怎么办?此外,请参见StackOverflow中的相同问题,但不起作用

您尚未输入“example2”子级的路径解析:

{ path:"for", component: ForComponent },
      { path:"example1", component: Example1Component },
      { path:"example2",component: Example2Component ,
          children: [          
          { path:"india",component:Child1Component },
          { path:"child2",component:Child2Component },
          { path:"child3",component:Child3Component }
          ]
      }

子数组中没有
印度
作为路径时,它如何匹配
印度
。您需要它,或者像
路径:“:country”
这样的参数路径:

因此,解决方案1:

{ path:"example2",component: Example2Component ,
  children: [          
    { path:"india",component:Child1Component },
    // ...
  ]
} 
或使用参数路径:

{ path:"example2",component: Example2Component ,
  children: [          
    { path:":country",component:Child1Component },
    // ...
  ]
} 

在第二个解决方案中,您编写的另一件事是:
在参数名称之前,这到底是什么意思?它工作得很好,但有了它,我想执行一项任务,比如单击它导航到另一页并显示详细信息的特定链接,但现在它在同一页上打开。请帮助