當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。