Cannot read property 'outlets' of null
For future reference: I got this error when using [routerLink]
with an array which looked like ['/foo', null]
. Fixed it by supplying an object instead of null
.
Most times this has nothing to do with your route configuration but happens when you try to pass in a dynamic data as a parameter to the route for instance.
<a [routerLink]="['/user', user?.id]" />user profile</a>
The user.id is dynamic and at the point where the page is initialized, the user object might be null
hence the error.
A quick fix to this will be to add an ng-if to the link, this will force the link to initialize only when the user object is available.
<a [routerLink]="['/user', user?.id]" *ngIf="user" />user profile</a>