Angular 2 Router strange null call

Problem

Im loading some menu items from the WordPress Rest API, then navigate to the page/:id with the correct id of the wordpress page. Everything works fine except of that:

Read More

Early when my page is loading I get this null call in the network section of the chrome developer. This is locally, on my server its also a 404 NOT FOUND.

www.mydomain.com/null

Setup

  • Angular 2 + Typescript (Angular 2 RC2, Router 3.0.0-alpha.6)
  • WordPress REST API

Code

Template

<header></header>
<router-outlet></router-outlet>
<footer></footer>

Routing

export const routes: RouterConfig = [
  { path: '/page/:id', component: PageComponent },
  { path: '/page/home', component: PageComponent, index: true }
];

Header.ts

this.myService.getNavigation()
    .subscribe(
        menuItems => {
            this.menuItems = menuItems;

            this.router.navigate(['/page', this.menuItems[0].title]);
        },
        error =>  this.errorMessage = <any>error);

Main.ts

bootstrap(AppComponent, [
    ...APP_ROUTER_PROVIDERS,
    ...HTTP_PROVIDERS,
    ...ROUTER_PROVIDERS,
    ...ENV_PROVIDERS,
    { provide: LocationStrategy, useClass: HashLocationStrategy }
  ])

Assumption

I guess it has something to do with my routing setup. When I comment out the <router-outlet> it does not happen, everything else works good.

Question

What is this strange call at /null and how can I avoid it?

Related posts

Leave a Reply

1 comment