2017-03-13 106 views
0

我在Angular 2应用程序中创建了一些儿童路线。Angular 2中的空儿童路线

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

当我访问http://localhost:4200/app/addhttp://localhost:4200/app/history一切都很好。

但在http://localhost:4200/app情况下,我得到了一个错误:

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 

任何想法?

+0

是'道: 'add''一个错字(而不是'' app'')? –

+0

不,“app”有3个孩子。一个空的,'添加'和'历史' –

+0

然后请在你的代码中显示'app'路由。 –

回答

1

如果您有没有空路径('')子路由使用pathMatch: 'full'

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