简体   繁体   English

空子路线在Angular 2中

[英]Empty child route in Angular 2

I've created some child routes in my Angular 2 app. 我在Angular 2应用中创建了一些子路线。

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

When I'm accessing http://localhost:4200/app/add or http://localhost:4200/app/history everything is fine. 当我访问http:// localhost:4200 / app / addhttp:// localhost:4200 / app / history时,一切都很好。

But in case of http://localhost:4200/app I've got an error : 但是在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

Any ideas ? 有任何想法吗 ?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM