本文整理汇总了TypeScript中@angular/router.RouterModule类的典型用法代码示例。如果您正苦于以下问题:TypeScript RouterModule类的具体用法?TypeScript RouterModule怎么用?TypeScript RouterModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RouterModule类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
import { ModuleWithProviders } from '@angular/core';
import { RouterModule } from '@angular/router';
import * as view from './view/index';
export const appRouting: ModuleWithProviders = RouterModule.forRoot([
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: '', component: view.LayoutComponent, children: [
{ path: 'home', component: view.HomeComponent },
] }
], { enableTracing: false, useHash: true });
export const VIEWS: any[] = [
view.LayoutComponent,
view.HomeComponent
];
示例2:
/**
* Created by slashhuang on 16/9/30.
* 路由模块
* 主程序入口提供路由服务,angular2目前在路由层面默认在topLevel需要定义router
*/
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const mainRoutes: Routes = [
{
path:'',
redirectTo:'',
pathMatch:'full'
}
];
export const AppRouting: ModuleWithProviders = RouterModule.forRoot(mainRoutes);
示例3:
import { ModuleWithProviders } from "@angular/core";
import { RouterModule } from "@angular/router";
import { SupportComponent } from "./support.component";
export const routing: ModuleWithProviders = RouterModule.forChild([
{ path: "support", component: SupportComponent},
]);
示例4:
{ path: 'button', component: ButtonDemoComponent },
{ path: 'card', component: CardDemoComponent },
{ path: 'radio', component: RadioDemoComponent },
{ path: 'sidenav', component: SidenavDemoComponent },
{ path: 'slide-toggle', component: SlideToggleDemoComponent },
{ path: 'slider', component: SliderDemoComponent },
{ path: 'progress-circle', component: ProgressCircleDemoComponent },
{ path: 'progress-bar', component: ProgressBarDemoComponent },
{ path: 'portal', component: PortalDemoComponent },
{ path: 'overlay', component: OverlayDemoComponent },
{ path: 'checkbox', component: CheckboxDemoComponent },
{ path: 'input', component: InputDemoComponent },
{ path: 'toolbar', component: ToolbarDemoComponent },
{ path: 'icon', component: IconDemoComponent },
{ path: 'list', component: ListDemoComponent },
{ path: 'menu', component: MenuDemoComponent },
{ path: 'live-announcer', component: LiveAnnouncerDemoComponent },
{ path: 'gestures', component: GesturesDemoComponent },
{ path: 'grid-list', component: GridListDemoComponent },
{ path: 'tabs', component: TabsDemoComponent },
{ path: 'button-toggle', component: ButtonToggleDemoComponent },
{ path: 'baseline', component: BaselineDemoComponent },
{ path: 'ripple', component: RippleDemoComponent },
{ path: 'dialog', component: DialogDemoComponent },
{ path: 'tooltip', component: TooltipDemoComponent },
]
}
];
export const demoRouting : ModuleWithProviders = RouterModule.forChild(demoRoutes);
示例5:
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './components/home/home.component';
import { FuncionesComponent } from './components/funciones/funciones.component';
import { FuncionRangosComponent } from './components/funcion-rangos/funcion-rangos.component';
const APP_ROUTES: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'funciones', component: FuncionesComponent },
{ path: 'funcion-rangos/:index', component: FuncionRangosComponent },
{ path: '**', pathMatch: 'full', redirectTo: 'home' }
];
export const APP_ROUTING = RouterModule.forRoot(APP_ROUTES, {useHash:true});
示例6:
import { Routes,RouterModule } from '@angular/router';
import { CourseComponent } from './course.component';
import { CourseListComponent } from './course-list.component';
import {PageNotFoundComponent } from '../pagenotfound.component';
const courseRoutes: Routes = [
{ path: 'course', component: CourseComponent },
{
path: 'courselist',
component: CourseListComponent,
data: {
title: 'Heroes List'
}
}
];
export const courseRoutingProviders: any[] = [
];
export const courseRouting = RouterModule.forChild(courseRoutes);
示例7:
import { RouterModule } from '@angular/router';
import { HomeComponent } from './home.component';
export const routing = RouterModule.forChild([
{
path: '',
component: HomeComponent
}
]);
示例8:
import {ModuleWithProviders} from "@angular/core"
import {FontAwesomeComponent} from "./+font-awesome/font-awesome.component";
import {GlyphiconsComponent} from "./+glyphicons/glyphicons.component";
import {FlagsComponent} from "./+flags/flags.component";
import {Routes, RouterModule} from "@angular/router";
export const iconsRoutes:Routes = [{
path: 'font-awesome',
component: FontAwesomeComponent
},
{
path: 'glyphicons',
component: GlyphiconsComponent
},
{
path: 'flags',
component: FlagsComponent
}
];
export const iconsRouting = RouterModule.forChild(iconsRoutes);
示例9:
/**
* Created by Martin on 11/08/16.
*/
import { Routes, RouterModule } from '@angular/router';
import { UserListComponent, UserDetailComponent } from './';
import { TopicListComponent } from '../topics';
const usersRoutes: Routes = [
{
path: 'users',
component: UserListComponent,
children: [
{ path: ':uuid', component: TopicListComponent },
{ path: '', component: UserDetailComponent }
]
},
];
export const usersRouting = RouterModule.forChild(usersRoutes);
示例10:
/**
* Created by stefania on 9/16/16.
*/
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ResourceTypeListComponent } from "./resource-type-list.component";
import { ResourceTypeDetailsComponent } from "./resource-type-detail.component";
import { NewResourceTypeComponent } from "./new-resource-type.component";
const resourceTypesRoutes: Routes = [
{
path: 'resourceType',
component: ResourceTypeListComponent
},
{
path: 'resourceType/detail/:name',
component: ResourceTypeDetailsComponent
},
{
path: 'resourceType/new',
component: NewResourceTypeComponent,
},
];
export const resourceTypesRouting: ModuleWithProviders = RouterModule.forChild(resourceTypesRoutes);