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


TypeScript NativeScriptRouterModule.forRoot方法代码示例

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


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

示例1: makeExampleModule

function makeExampleModule(componentType) {
    let imports: any[] = [NativeScriptAnimationsModule, ExampleModule];
    if (componentType.routes) {
        imports.push(NativeScriptRouterModule.forRoot(componentType.routes));
    }
    let exports: any[] = [];
    if (componentType.exports) {
        exports = componentType.exports;
    }
    let entries = [];
    if (componentType.entries) {
        entries = componentType.entries;
    }
    entries.push(componentType);

    let providers = [{ provide: ErrorHandler, useClass: MyErrorHandler }];
    if (componentType.providers) {
        providers = [...providers, componentType.providers];
    }

    @NgModule({
        bootstrap: [componentType],
        imports,
        entryComponents: entries,
        declarations: [...entries, ...exports],
        providers,
        exports,
    })
    class ExampleModuleForComponent { }

    return ExampleModuleForComponent;
}
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:32,代码来源:app.ts

示例2: describe

describe("NativeScriptRouterModule.forRoot", () => {
    beforeEach(nsTestBedBeforeEach(
        [RouterTestComponent],
        [],
        [NativeScriptRouterModule.forRoot([])],
        []));

    afterEach(nsTestBedAfterEach());

    it("should provide nativescript routing services", () => {
        return nsTestBedRender(RouterTestComponent).then((fixture) => {
            const injector = fixture.componentRef.injector

            assert.instanceOf(injector.get(LocationStrategy, null), NSLocationStrategy);
            assert.instanceOf(injector.get(RouterExtensions, null), RouterExtensions);
            assert.instanceOf(injector.get(RouteReuseStrategy, null), NSRouteReuseStrategy);
        });
    });

    it("should provide nativescript routing directives", () => {
        return nsTestBedRender(RouterTestComponent).then((fixture) => {
            const linkDirective = fixture.componentRef.instance.nsRouterLink;
            assert.instanceOf(linkDirective, NSRouterLink);
        });
    });
});
开发者ID:NativeScript,项目名称:nativescript-angular,代码行数:26,代码来源:router-module-tests.ts

示例3:

        path: "ListViewSwipeDisableComponent",
        loadChildren: './examples/listview-examples.module#ListViewExamplesModule',
        data: {
            "title": "Disable\\Enable"
        }
    },
    {
        path: "ListViewWithBigDataComponent",
        loadChildren: './examples/listview-examples.module#ListViewExamplesModule',
        data: {
            "title": "Initially load  10 000 items"
        }
    },
    {
        path: "ListviewHorizontalWithVariableItemWidthComponent",
        loadChildren: './examples/listview-examples.module#ListViewExamplesModule',
        data: {
            "title": "Horizontal with Variable item's width"
        }
    },
    {
        path: "ListViewGroupSwipeLoadPullComponent",
        loadChildren: './examples/listview-examples.module#ListViewExamplesModule',
        data: {
            "title": "Group, Swipe, Load and Pull"
        }
    }
];

export const routing = NativeScriptRouterModule.forRoot(APP_ROUTES);
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:30,代码来源:app.routing.ts


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