未找到页面的angular2路由

未找到页面的angular2路由,angular,routing,Angular,Routing,我试着用儿童击溃。我的主路由模块(在根目录中): 和子路由模块(在子目录中): 我对这个路由有一个问题{path:'**',component:NotFoundComponent}。Angular2先看到这条路线,再看到任何子路线。因此,url“”显示notFound组件。如果我删除notFound路由,''可以正常工作。 如何声明未找到的路线并在最后一轮(在子路线之后)说Angular2检查它 甘特·泽克鲍尔,你是说像这样的一个人吗 RouterModule.forChild([

我试着用儿童击溃。我的主路由模块(在根目录中):

和子路由模块(在子目录中):

我对这个路由有一个问题
{path:'**',component:NotFoundComponent}
。Angular2先看到这条路线,再看到任何子路线。因此,url“”显示notFound组件。如果我删除notFound路由,''可以正常工作。 如何声明未找到的路线并在最后一轮(在子路线之后)说Angular2检查它

甘特·泽克鲍尔,你是说像这样的一个人吗

RouterModule.forChild([
      {
        path: '',
        children: [
          {
            path: 'partner-program',
            component: PPComponent,
            children: [
              {
                path: '',
                redirectTo: 'members',
                pathMatch: 'full'
              },
              {
                path: 'members',
                component: MembersComponent,
              },
              {
                path: 'history',
                component: HistoryComponent,
              },
            ]
          }
        ]
      }
    ])

将这些模块导入主模块时,请确保在末尾添加AppRoutingModule。所有这些都是关于路线注册的顺序

当您将这些模块导入主模块时,请确保在末尾添加AppRoutingModule。这都是关于路由注册的顺序

我认为您的
PPRoutingModule
路由没有正确配置为子路由。子管线必须是父管线的子管线<代码>'http://localhost:3000/partner-程序“只能在它是`{path:'',重定向到:'home',pathMatch:'full'},`(空路径)的子路由时匹配,但它不是。我认为您的
PPRoutingModule
路由未正确配置为子路由。子管线必须是父管线的子管线<代码>'http://localhost:3000/partner-程序“仅当它是`{path:'',重定向到:'home',pathMatch:'full'},`(空路径)的子路由时才能匹配,但它不是。
import { NgModule }     from '@angular/core';
import { RouterModule } from '@angular/router';

import { PPComponent } from './pp.component';
import { MembersComponent } from './members/members.component';
import { HistoryComponent } from './history/history.component';


@NgModule({
  imports: [
    RouterModule.forChild([
      {
        path: 'partner-program',
        component: PPComponent,
        children: [
          {
            path: '',
            redirectTo: 'members',
            pathMatch: 'full'
          },
          {
            path: 'members',
            component: MembersComponent,
          },
          {
            path: 'history',
            component: HistoryComponent,
          },
        ]
      },


    ])
  ],
  exports: [
    RouterModule
  ]
})
export class PPRoutingModule { }
RouterModule.forChild([
      {
        path: '',
        children: [
          {
            path: 'partner-program',
            component: PPComponent,
            children: [
              {
                path: '',
                redirectTo: 'members',
                pathMatch: 'full'
              },
              {
                path: 'members',
                component: MembersComponent,
              },
              {
                path: 'history',
                component: HistoryComponent,
              },
            ]
          }
        ]
      }
    ])