路由父组件Angular 2

时间:2017-07-17 23:37:27

标签: angular typescript

我有这条路径

mydomain/app/form/hold

我需要在访问

时创建一条路线
mydomain/app/form -> app/form/form.component

重定向到

mydomain/app/dashboard -> app/dashboard/dashboard.component

这是mya form route

import { Dashboard } from '../dashboard/dashboard.component';
const routes: Routes = [
  { path: '', children: [
      { path: '',redirectTo: 'dashboard',  pathMatch: 'full' },
      { path: 'hold',  loadChildren: () => System.import('./hold/hold.module')  },
      { path: 'dashboard', component:Dashboard}
    ]
  },
];
@NgModule({
  declarations: [
  Dashboard
  ],


imports: [
    Select2Module,
    NKDatetimeModule,
    CommonModule,
    FormsModule,
    RouterModule.forChild(routes)
  ],
  schemas:  [ CUSTOM_ELEMENTS_SCHEMA ]
})
export default class FormModule {
  static routes = routes;
}

我的dashboard.module

export const routes = [
  { path: '', component: Dashboard, pathMatch: 'full' }
];


@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild(routes),
    WidgetModule,
    UtilsModule,
    RickshawChartModule
  ],
  declarations: [
    Dashboard,
    GeoLocationsWidget,
    BootstrapCalendar,
    MarketStatsWidget
  ]
})
export default class DashboardModule {
  static routes = routes;
}

问题是当我在NgModule声明中添加Dashboard时出现错误,当从声明中删除仪表板时我也得到了错误。我无法重定向到仪表板组件

0 个答案:

没有答案