2017-03-13 4 views
0

Ich habe in meiner Angular 2 App einige Kinderrouten erstellt.Leeres Kind Route in Angular 2

export const AFTER_LOGIN_ROUTES:Routes=[ 
    {path:'',component:LatestPositionComponent}, 
    {path:'add',component:AddNewFriendComponent}, 
    {path:'history',component:HistoryComponent} 
    ]; 

Wenn ich http://localhost:4200/app/add oder http://localhost:4200/app/history alles Zugriff ist in Ordnung.

Aber im Fall von http://localhost:4200/app Ich habe einen Fehler bekommt:

EXCEPTION: Uncaught (in promise): Error: Error in :0:0 caused by: Cannot read property 'firstChild' of null 
Error: Error in :0:0 caused by: Cannot read property 'firstChild' of null 
    at ViewWrappedError.ZoneAwareError 

Irgendwelche Ideen?

+0

Ist 'Pfad: 'add'' ein Tippfehler (statt'' app'')? –

+0

Nein, die 'App' hat 3 Kinder. Eine leere, 'add' und' history' –

+0

Dann zeigen Sie bitte auch die 'app' Route in Ihrem Code. –

Antwort

1

Wenn Sie einen leeren Pfad haben (''), die nicht Kind hat Routen verwenden pathMatch: 'full'

{path:'',component:LatestPositionComponent, pathMatch: 'full'},