-
-
Notifications
You must be signed in to change notification settings - Fork 241
Fix navigate with clearHistory to a lazy loaded module #637
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
Conversation
Can't wait to have PR! Great job! Any tips on how to use this PR without having to wait for the repo to be updated? |
I've duplicate the module in my app and use it as follows !! Does not compile with AOT, removed from PR !! 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 "nativescript-angular/router/ns-router-link";
import { NSRouterLinkActive } from "nativescript-angular/router/ns-router-link-active";
import { PageRouterOutlet } from "nativescript-angular/router/page-router-outlet";
import { NSLocationStrategy, LocationState } from "nativescript-angular/router/ns-location-strategy";
import { NativescriptPlatformLocation } from "nativescript-angular/router/ns-platform-location";
import { RouterExtensions } from "nativescript-angular/router/router-extensions";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
export { PageRoute } from "nativescript-angular/router/page-router-outlet";
export { RouterExtensions } from "nativescript-angular/router/router-extensions";
export { NSModuleFactoryLoader } from "nativescript-angular/router/ns-module-factory-loader";
export type LocationState = LocationState;
@NgModule({
declarations: [
NSRouterLink,
NSRouterLinkActive,
PageRouterOutlet
],
imports: [
RouterModule,
NativeScriptModule
],
exports: [
RouterModule,
NSRouterLink,
NSRouterLinkActive,
PageRouterOutlet
],
schemas: [NO_ERRORS_SCHEMA]
})
export class CustomRouterModule {
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders {
return {
ngModule: CustomRouterModule,
providers: [
NSLocationStrategy,
{ provide: LocationStrategy, useExisting: NSLocationStrategy },
NativescriptPlatformLocation,
{ provide: PlatformLocation, useClass: NativescriptPlatformLocation },
RouterExtensions,
...RouterModule.forRoot(routes, config).providers
]
};
}
static forChild(routes: Routes): ModuleWithProviders {
return {
ngModule: CustomRouterModule,
providers: RouterModule.forChild(routes).providers
};
}
} |
This looks great, but unfortunately it breaks AoT compilation for me: ~/t/test-router $ ./node_modules/.bin/ngc -p tsconfig.aot.json
Can't resolve all parameters for provideLocationStrategy in /home/local/TELERIK/hdeshev/tmp/test-router/node_modules/@angular/router/src/router_module.d.ts: ([object Object], ?, [object Object]). The error goes away if I try the master branch. Any ideas? |
It seems that the compiler is unable to resolve the @Inject(APP_BASE_HREF) parameter,. According to this thread angular/angular#8623, It causes the compiler to flag the dependency with |
I've find another way, will do PR tomorrow if travis is OK |
I'm golden, let's get it in! |
@hdeshev will this get merged in time for 2.5 release? |
Thanks, great work! I tested it with @tskweres's project from #643. Too bad about the router module improvements. :( @lfabreges, can you squash your commits and I'll try to get them in the upcoming release. |
@danielgek Yes, that's the plan. I hope I can move it to the release branch tomorrow. |
#643 with respect to this bug, I'm still seeing the transitions issue. I clone my example repo, update core modules and re-add platform ios and build. Any thoughts on if 2.5 included the fix? Or am I missing a step? |
got it working with tns update next |
Fix the navigation using extras like
clearHistory
to a lazy loaded module. Providers, especiallyNSLocationStrategy
were instantiated multiple times.