It seems that routes that are registered within ng2+ module using the @ui-router/angular-hybrid
are not recognized on initial load/reload. The same route is working if e.g. navigated by typing the url.
I've followed the official upgrade docs from @ui-router/angular-hybrid
Here is the ng2+ AppModule
code:
const states: NgHybridStateDeclaration[] = [
{
name: 'x',
url: '/x',
component: XComponent
}
];
enableProdMode();
@NgModule({
imports: [
BrowserModule,
UpgradeModule,
UIRouterUpgradeModule.forRoot({states: states}),
ComponentsModule,
DirectivesModule
],
declarations: [AppComponent],
exports: [],
entryComponents: [],
providers: [],
bootstrap: []
})
export class Ng2AppModule {
constructor(
@Inject(forwardRef(() => UpgradeModule)) private upgrade: UpgradeModule,
@Inject(forwardRef(() => Config)) private config: Config
) {}
ngDoBootstrap() {
this.upgrade.bootstrap(document as any, ['app'], { strictDi: true });
}
}
And the bootstrapping logic:
AppModule.config([
'$urlServiceProvider',
($urlService: UrlService) => $urlService.deferIntercept()
]);
getConfig()
.then((config: Config) => {
console.log('CONFIG::::', config);
AppModule.constant('config', config);
setAngularLib(angular);
platformBrowserDynamic([
{
provide: Config,
useValue: config
}
])
.bootstrapModule(Ng2AppModule)
.then(platformRef => {
platformRef.injector.get<NgZone>(NgZone).run(() => {
const urlService = platformRef.injector.get(UIRouter).urlService;
urlService.listen();
urlService.sync();
});
downgradeSharedComponents(AppModule);
});
})
P.S. Existing angularjs routes are working properly, the problem is with routes registered within the ng2+ module.
Any help is appreciated, thanks ^^