Angular 如何获取未激活的子路由

Angular how to get the non activated children routes

在 Angular 中,您始终可以在组件中注入 ActivatedRoute 以获取对当前激活路由的引用。

它有一个 属性 children 其中:

Contains all the child routes activated under the current route.

我想知道如何获得 所有 子路线(以及未激活的路线)。

您可以使用 route.routeConfig.children 获取路由器中定义的子项。