本文整理匯總了TypeScript中@angular/router.RouterModule.forChild方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript RouterModule.forChild方法的具體用法?TypeScript RouterModule.forChild怎麽用?TypeScript RouterModule.forChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/router.RouterModule
的用法示例。
在下文中一共展示了RouterModule.forChild方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
import {AboutComponent} from "./about.component";
import {RouterModule} from "@angular/router";
const routes = [
{path: '', component: AboutComponent}
];
export default RouterModule.forChild(routes);
示例2:
import { ModuleWithProviders } from '@angular/core';
import { RouterModule } from '@angular/router';
import { WarehouseCmp } from './warehouse';
import { WarehouseDetailCmp} from './detail/detail';
import { WarehouseImportCmp } from './import/import';
export const routing: ModuleWithProviders = RouterModule.forChild([
{ path: 'warehouse', component: WarehouseCmp },
{path: 'warehouse-detail/:id', component: WarehouseDetailCmp },
{path: 'warehouse-import', component: WarehouseImportCmp },
]);
示例3:
import { NgModule } from '@angular/core';
import { CommonModule, } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';
import { ModuleWithProviders } from '@angular/core';
import {AboutComponent} from './about.component';
const routes: Routes =[
{path: '',
component: AboutComponent,
children: [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{path: '**', redirectTo: 'home' }
]
}
];
export const routing = RouterModule.forChild(routes);
示例4:
{
path: 'crisis-center',
component: CrisisCenterComponent,
children: [
// #docregion admin-route
{
path: 'admin',
component: CrisisAdminComponent,
canActivate: [AuthGuard]
},
// #enddocregion admin-route
// #docregion crisis-detail-resolve
{
path: ':id',
component: CrisisDetailComponent,
canDeactivate: [CanDeactivateGuard],
resolve: {
crisis: CrisisDetailResolve
}
},
// #enddocregion crisis-detail-resolve
{
path: '',
component: CrisisListComponent
}
]
}
];
export const crisisCenterRouting: ModuleWithProviders = RouterModule.forChild(crisisCenterRoutes);
示例5:
import { RouterModule, Routes } from '@angular/router';
import { AirexchangeFormComponent } from './airexchange-form/airexchange-form.component';
const routes: Routes = [
{ path: '', component: AirexchangeFormComponent }
];
export const AirexchangeRoutes = RouterModule.forChild(routes);
示例6:
import { ModuleWithProviders } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ContactComponent } from './contact.component.3';
export const routing: ModuleWithProviders = RouterModule.forChild([
{ path: 'contact', component: ContactComponent}
]);
示例7:
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ChildCheckinComponent } from './child-checkin.component';
import { RoomComponent } from './room';
const childCheckinRoutes: Routes = [
{
path: 'child-checkin',
component: ChildCheckinComponent,
children: [
{
path: 'room',
component: RoomComponent
},
]
}
];
export const childCheckinRouting: ModuleWithProviders = RouterModule.forChild(childCheckinRoutes);
示例8:
loadChildren: "../pages/agentAnalytics/agentAnalytics.module#AgentAnalyticsModule"
},
{
path: "usersdata",
loadChildren: "../pages/leads/leads.module#LeadsModule"
},
{
path: "support",
loadChildren: "../pages/support/support.module#SupportModule"
},
//---------------------------------------------------------->
//Page Layouts
//---------------------------------------------------------->
//
//---------------------------------------------------------->
//Helper Classes
//---------------------------------------------------------->
{
path: "helper-classes",
loadChildren: "../pages/helper-classes/helper-classes.module#HelperClassesModule"
}
]
},
// 404 Page Not Found
{ path: "**", redirectTo: "dashboards" }
];
export const LayoutRoutes = RouterModule.forChild(LAYOUT_ROUTES);
示例9:
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './ss-dashboard.component';
export const routing: ModuleWithProviders = RouterModule.forChild([
{ path: 'dashboard', component: DashboardComponent}
]);
示例10:
import { ModuleWithProviders } from '@angular/core';
import { RouterModule } from '@angular/router';
import { BootstrapDemo } from './bootstrap-demo';
import { BootstrapDemoPage } from './bootstrap-demo-page/bootstrap-demo-page';
import { ModalCustomisationWizard } from './modal-customisation-wizard/modal-customisation-wizard';
export const routing: ModuleWithProviders = RouterModule.forChild([
{ path: 'bootstrap-demo', component: BootstrapDemo, children: [
{ path: '', component: BootstrapDemoPage, terminal: true },
// { path: 'customizeModals', component: ModalCustomisationWizard }
]
}
]);