Angular 子路由模块未加载同一页面中的内容

Angular 子路由模块未加载同一页面中的内容,angular,components,router,router-outlet,Angular,Components,Router,Router Outlet,我正在用angular 2开发小型应用程序。[Authentication+2屏幕],我在管理路由参数时遇到问题 我对路由文件、app.routing.ts主体和a子路由文件admin.routing.ts进行了重定向,每当我成功进行身份验证时,就会重定向到home路径,在此页面中,我必须重定向到由子路由器管理的组件,每当我点击链接时,我都希望在同一屏幕上加载内容,但路由器会重新加载整个页面 app.routing.ts const appRoutes: Routes = [

我正在用angular 2开发小型应用程序。[Authentication+2屏幕],我在管理路由参数时遇到问题

我对路由文件、app.routing.ts主体和a子路由文件admin.routing.ts进行了重定向,每当我成功进行身份验证时,就会重定向到home路径,在此页面中,我必须重定向到由子路由器管理的组件,每当我点击链接时,我都希望在同一屏幕上加载内容,但路由器会重新加载整个页面

app.routing.ts

      const  appRoutes: Routes = [
      {
        path: 'home',
        component : HomeComponent,
        canActivate : [AuthGard]
      },
      {
        path: 'login',
        component : LoginComponent
      },
      {
        path: 'not-found',
        component: NotFoundComponent
      },
      {
        path: '',
        redirectTo: 'login',
        pathMatch: 'full'
      },
      {
        path: '**',
        redirectTo : 'not-found',
        pathMatch: 'full'
      }
  ];

  export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
adminRouting.ts(子项)

home.component.html

<app-template-component></app-template-component>
<app-sidebar-nav></app-sidebar-nav>
 <div class="wrapper">
  <div class="main-panel">

    <app-nav-bar></app-nav-bar>

    <div class="content">
      <div class="container-fluid">
          <router-outlet></router-outlet> ** Content expected to be loaded here  **
      </div>
    </div>

    <footer class="footer">
      <div class="container-fluid">
        <div class="copyright pull-right">
          &copy; <script>document.write(new Date().getFullYear())</script> S2M 2017
        </div>
      </div>
    </footer>

     </div>
</div>


它不会在指定的位置加载内容,而是加载另一个页面。

子路由应该这样定义

const  appRoutes: Routes = [
      {
        path: 'home',
        component : HomeComponent,
        canActivate : [AuthGard],
        children:[
        {
             path:'', 
             component:ChildComponent,
             children: appRoutesChild
         }
        ]
      },
      {
        path: 'login',
        component : LoginComponent
      },
      {
        path: 'not-found',
        component: NotFoundComponent
      },
      {
        path: '',
        redirectTo: 'login',
        pathMatch: 'full'
      },
      {
        path: '**',
        redirectTo : 'not-found',
        pathMatch: 'full'
      }
  ];
const  appRoutes: Routes = [
      {
        path: 'home',
        component : HomeComponent,
        canActivate : [AuthGard],
        children:[
        {
             path:'', 
             component:ChildComponent,
             children: appRoutesChild
         }
        ]
      },
      {
        path: 'login',
        component : LoginComponent
      },
      {
        path: 'not-found',
        component: NotFoundComponent
      },
      {
        path: '',
        redirectTo: 'login',
        pathMatch: 'full'
      },
      {
        path: '**',
        redirectTo : 'not-found',
        pathMatch: 'full'
      }
  ];