When im logged in, and navigate to otherpage or login i get the following error:
EXCEPTION: Uncaught (in promise): Error: Cannot find primary outlet to load 'customComponent'
Error: Cannot find primary outlet to load 'customComponent'
But when im not logged in, navigating works.
I also noticed that if i remove one of the router-outlets the navigation will work. Lets say i remove the router-outlet in loggedin, the navigation within user.username will work as normal.
How come? How can i make it work as it should? if not logged in, show router outlet there, else if im online, show it somewhere else?
Code:
<div *ngIf="user.username">
<a routerLink="/murder" routerLinkActive="active">Murder</a>
<a routerLink="/login" routerLinkActive="active">Login</a>
<div>
<router-outlet></router-outlet>
</div>
</div>
<div *ngIf="loggedin == false">
<a routerLink="/murder" routerLinkActive="active">Murder</a>
<a routerLink="/login" routerLinkActive="active">Login</a>
// other things
<div>
<router-outlet></router-outlet>
</div>
</div>
Update:
i made the router-outlet in login to:
<router-outlet name="regular"></router-outlet>
and outside:
<router-outlet name="aux"></router-outlet>
and changed my routing:
path: 'murder',
component: MurderComponent,
outlet: 'regular'
but when i navigate i get:
EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'murder'
how come?
full code routing:
RouterModule.forRoot([
{
path: 'login',
component: LoginhandlerComponent,
outlet: 'aux'
},
{
path: 'murder',
component: MurderComponent,
outlet: 'regular'
},
]
)