本文整理匯總了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);