当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Routes.forEach方法代码示例

本文整理汇总了TypeScript中@angular/router.Routes.forEach方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Routes.forEach方法的具体用法?TypeScript Routes.forEach怎么用?TypeScript Routes.forEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/router.Routes的用法示例。


在下文中一共展示了Routes.forEach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: updateRoutingInfo

 function updateRoutingInfo(routes: Routes, path: string) {
     routes.forEach(route => {
         if(!route.data) { return; }
         const fullLink = [path, route.path].join('/');
         route.data.link = fullLink;
         if(route.children) {
             updateRoutingInfo(route.children, fullLink);
         }
     });
 }
开发者ID:DevExpress,项目名称:SalesViewer,代码行数:10,代码来源:routes.service.ts

示例2:

    { path: "edit/:id", component: EditComponent, data: { title: "Edit Check" } },
    { path: "edit/:id/:copy", component: EditComponent, data: { title: "Copy Check" } },
    { path: "settings", component: SettingsComponent, data: { title: "Settings", noSettingsLink: true } },
    { path: "details/:id", component: DetailsComponent, data: { title: "Details" } },
    { path: "login", component: LoginComponent, data: { title: "Login", noDashboardLink: true } },
    { path: "user", component: UserComponent, data: { title: "User" } },
    { path: "init", component: InitComponent, data: { title: "SystemChecker Init", noDashboardLink: true } },
    { path: "**", component: PageNotFoundComponent, data: { title: "Not Found" } },
];

routes.forEach(x => {
    if (!x.canDeactivate) {
        x.canDeactivate = [];
    }
    x.canDeactivate.push(CanDeactivateGuard);

    if (x.path === "login" || x.path === "init") { return; }
    if (!x.canActivate) {
        x.canActivate = [];
    }
    x.canActivate.push(AuthGuard);
});

@NgModule({
    imports: [
        CommonModule,
        BrowserModule,
        BrowserAnimationsModule,
        HttpModule,
        FormsModule,
        RouterModule.forRoot(routes),
        JwtModule.forRoot({
开发者ID:MattJeanes,项目名称:SystemChecker,代码行数:32,代码来源:app.module.ts

示例3:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PlanOfWork } from './components/plan-of-work/plan-of-work';
import { TestSets } from './components/testset/testset';

export const mainMenuRoutes: Routes = [
    { path: 'planofwork', component: PlanOfWork },
    { path: 'testset', component: TestSets },
    { path: 'testing', component: PlanOfWork },
    { path: 'settings', component: PlanOfWork },
    { path: 'tools', component: PlanOfWork }
];

const routes: Routes = [
    { path: 'new', redirectTo: 'planofwork/12?regionId=13', pathMatch: 'full' },
    { path: 'planofwork/:id', component: PlanOfWork }
];

mainMenuRoutes.forEach(r => routes.push({ path: r.path, component: r.component }));

@NgModule({
    imports: [
        RouterModule.forRoot(
            routes,
            // { enableTracing: true } // <-- debugging purposes only
        )
    ],
    exports: [RouterModule]
})
export class AppRoutingModule { }
开发者ID:asdman384,项目名称:tracker2,代码行数:30,代码来源:app.routing.module.ts


注:本文中的@angular/router.Routes.forEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。