Skip to content

Fix(router): export module loader, don't use it by default #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions nativescript-angular/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NgModule, ModuleWithProviders, NO_ERRORS_SCHEMA, NgModuleFactoryLoader } from "@angular/core";
import { NgModule, ModuleWithProviders, NO_ERRORS_SCHEMA } from "@angular/core";
import { RouterModule, Routes, ExtraOptions } from "@angular/router";
import { LocationStrategy, PlatformLocation } from "@angular/common";
import { NSRouterLink } from "./router/ns-router-link";
Expand All @@ -8,7 +8,7 @@ import { NSLocationStrategy, LocationState } from "./router/ns-location-strategy
import { NativescriptPlatformLocation } from "./router/ns-platform-location";
import { RouterExtensions } from "./router/router-extensions";
import { NativeScriptModule } from "./nativescript.module";
import { NsModuleFactoryLoader } from "./router/ns-module-factory-loader";
export { NSModuleFactoryLoader } from "./router/ns-module-factory-loader";

export { PageRoute } from "./router/page-router-outlet";
export { RouterExtensions } from "./router/router-extensions";
Expand Down Expand Up @@ -42,14 +42,7 @@ export type LocationState = LocationState;
})
export class NativeScriptRouterModule {
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders {
let moduleWithProviders = RouterModule.forRoot(routes, config);

// Override the stock SystemJsNgModuleLoader
moduleWithProviders.providers.push(
{ provide: NgModuleFactoryLoader, useClass: NsModuleFactoryLoader },
);

return moduleWithProviders;
return RouterModule.forRoot(routes, config);
}

static forChild(routes: Routes): ModuleWithProviders {
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular/router/ns-module-factory-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const FACTORY_CLASS_SUFFIX = "NgFactory";
const FACTORY_PATH_SUFFIX = ".ngfactory";

@Injectable()
export class NsModuleFactoryLoader implements NgModuleFactoryLoader {
export class NSModuleFactoryLoader implements NgModuleFactoryLoader {
private offlineMode: boolean;

constructor(private compiler: Compiler) {
Expand Down
14 changes: 7 additions & 7 deletions ng-sample/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
//profiling.start("application-start");

// "nativescript-angular/application" import should be first in order to load some required settings (like globals and reflect-metadata)
import {
NativeScriptModule,
platformNativeScriptDynamic,
NativeScriptRouterModule,
import {
NativeScriptModule,
platformNativeScriptDynamic,
NativeScriptRouterModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
routerTraceCategory,
routerTraceCategory,
rendererTraceCategory,
listViewTraceCategory,
PAGE_FACTORY,
PageFactory,
PAGE_FACTORY,
PageFactory,
PageFactoryOptions,
onAfterLivesync,
onBeforeLivesync
Expand Down
4 changes: 3 additions & 1 deletion tests/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
routerTraceCategory,
NativeScriptRouterModule,
NativeScriptFormsModule,
NSModuleFactoryLoader,
APP_ROOT_VIEW
} from "nativescript-angular";
import { AppComponent } from "./app.component";
Expand All @@ -23,7 +24,7 @@ import { SinglePageMain, routes as singlePageRoutes } from "./single-page-main.c
import { LazyLoadMain, routes as lazyLoadRoutes } from "./lazy-load-main";
import { FirstComponent } from "./first.component";
import { SecondComponent } from "./second.component";
import { OpaqueToken, NgModule } from "@angular/core";
import { OpaqueToken, NgModule, NgModuleFactoryLoader } from "@angular/core";

import { PageNavigationApp } from "./snippets/navigation/page-outlet";
import { NavigationApp } from "./snippets/navigation/router-outlet";
Expand Down Expand Up @@ -137,6 +138,7 @@ class MultiPageModule { }
providers: [
rootViewProvider,
lazyLoadHooksLogProvider,
{ provide: NgModuleFactoryLoader, useClass: NSModuleFactoryLoader },
]
})
class LazyLoadModule { }
Expand Down