本文整理汇总了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;
}
示例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);
});
});
});
示例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);