Good Morning, I have a question about routers, I defined my app.routing.module.ts:
import {NgModule} from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const APP_ROUTES: Routes = [
{path: 'livros', loadChildren: './livros/livros.module'},
];
@NgModule({
imports: [RouterModule.forRoot(APP_ROUTES)],
exports: [RouterModule]
})
export class AppRoutingModule {}
and my livros.routing.module.ts:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {LivrosComponent} from './livros.component';
const LIVROS_ROUTES: Routes = [
{path: '', component: LivrosComponent},
];
@NgModule({
imports: [RouterModule.forChild(LIVROS_ROUTES)],
exports: [RouterModule]
})
export class LivrosRoutingModule {}
When I start my app I get this error:
TypeError: router.initialNavigation is not a function at RouterInitializer.push../node_modules/@angular/router/fesm5/router.js.RouterInitializer.bootstrapListener (router.js:5067) at core.js:4467 at Array.forEach () at ApplicationRef.push../node_modules/@angular/core/fesm5/core.js.ApplicationRef._loadComponent (core.js:4467) at ApplicationRef.push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.bootstrap (core.js:4405) at core.js:4205 at Array.forEach () at PlatformRef.push../node_modules/@angular/core/fesm5/core.js.PlatformRef._moduleDoBootstrap (core.js:4205) at core.js:4172 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
I searched for the solution and configured app.routing.module.ts with initialNavigation: false :
import {NgModule} from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const APP_ROUTES: Routes = [
{path: 'livros', loadChildren: './livros/livros.module'},
];
@NgModule({
imports: [RouterModule.forRoot(APP_ROUTES, {initialNavigation: false})],
exports: [RouterModule]
})
export class AppRoutingModule {}
but I get a new problem:
TypeError: router.setUpLocationChangeListener is not a function at RouterInitializer.push../node_modules/@angular/router/fesm5/router.js.RouterInitializer.bootstrapListener (router.js:5070) at core.js:4467 at Array.forEach () at ApplicationRef.push../node_modules/@angular/core/fesm5/core.js.ApplicationRef._loadComponent (core.js:4467) at ApplicationRef.push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.bootstrap (core.js:4405) at core.js:4205 at Array.forEach () at PlatformRef.push../node_modules/@angular/core/fesm5/core.js.PlatformRef._moduleDoBootstrap (core.js:4205) at core.js:4172 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
Have some new configuration in version 6? How can I solved this problem? What's happened in my app? Thank you.
{path: 'livros', loadChildren: './livros/livros.module#LivrosModule'},
But i am not sure if this is the problem in this case. – btx