My angular router is failing to load the latest component after a router change is made within the application. If I call the URL manually it will load the correct content however any use of routerLink or a call to router.navigate has no affect on the router-outlet content.
I have tried binding to router events and recalling the getContent function when there is a change and this fixes the issue when calling programmatically.
The project is pretty bare but the router:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ContentpaneComponent } from './contentpane/contentpane.component';
const routes: Routes = [
{ path: '', component: ContentpaneComponent },
{ path: 'post/:app', component: ContentpaneComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
And the container in app.component.html
<div class="above">
<app-sidebar></app-sidebar>
<div class="contentpane">
<router-outlet></router-outlet>
</div>
</div>
<app-terminal></app-terminal>
If there is any other code segments that would benefit please request in comments.
Here is the code containing the routerLink directives:
<div class="main">
<div class="logo">
O
</div>
<ul class="navbar">
<li *ngFor="let nav of navs">
<a routerLink="/{{nav.href}}" class="navitem">{{nav.title}}</a>
</li>
</ul>
</div>
EDIT: I am also getting a websocket error in the console:
WebSocket connection to 'ws://localhost:4200/sockjs-node/748/g0a4bxsw/websocket' failed: WebSocket is closed before the connection is established.
Not sure if it is a related issue.