Angular 5 EmptyError:制作子路线时没有顺序排列的元素 [英] Angular 5 EmptyError: no elements in sequence while making child routes
问题描述
当我在路由中使用子级时,无法从登录页面导航到仪表板页面:
I am not able to navigate from login page to dashboard page when I use children in routing as follows:
const appRoutes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent,pathMatch: 'full' },
{
path: 'dashboard',pathMatch: 'full', /* canActivate: [AuthGuard], */ component: DashboardComponent ,
children: [
{
path: 'online-submission/:moduleName',pathMatch: 'full', component: OnlineSubmissionComponent,
/* canActivate: [AuthGuard], */data:{
breadcrumb: "online-submission"
} ,
children: [
{ path: 'batch-upload-members',pathMatch: 'full', component: BatchUploadMembersComponent,
/* canActivate: [AuthGuard], */data:{
breadcrumb: "batch-upload-members"
} },
{ path: 'select-members',pathMatch: 'full', component: SelectMembersComponent,
/* canActivate: [AuthGuard], */data:{
breadcrumb: "select-members"
}
}
]
}
]
},
{ path: '**', component: PageNotFoundComponent }
];
但是,当我从路由中删除children属性并使它们的兄弟姐妹路由工作正常时。进行子航线行驶时会出现什么问题?我正在使用cli 1.6.0-rc.1
However when I remove the children attribute from the routes and make them siblings routing works fine. What is the issue when I make child routes ? I am using cli 1.6.0-rc.1
到目前为止我一直在尝试什么?
What I have tried so far ?
-
评论AuthGuard无法正常工作,因此问题不在于该部分
Commenting AuthGuard did not work so the problem is not with that part
我已经验证过,只有当我将它们作为孩子时路由(我需要制作面包屑)会出现此问题。如果所有路由均为同级路由,则路由会正常工作
I have verified that only when I have them as children routes(which I need for making breadcrumbs) this problem occurs. If all the routes are siblings, the routing works properly
使用了 {enableTracing:true}
RouterModule.forRoot
在这里找到 NavigationStart(id:4,url:'/ dashboard')
似乎是正确的URL DashboardComponent
used {enableTracing:true}
in the RouterModule.forRoot
where I find NavigationStart(id: 4, url: '/dashboard')
which seems correct url for DashboardComponent
在SO上搜索了类似的标题问题,但没有一个解决相同的问题:
searched on SO for similar titled questions but none has addressed the same issue:
Angular2 routing issues - Zone aware error No elements in sequence
Angular 2.0.1路由器EmptyError:顺序无元素
推荐答案
此错误是由于Angular路由器的最新版本引起的。
请删除还原的角度版本或在路径中添加pathMatch:'full'。
This bug is due to the last version of Angular's Router. Please remove revert back angular version or add pathMatch: 'full' to your routes.
export const userRoutes = [
{ path: 'profile', component: ProfileComponent, pathMatch: 'full' },
{ path: 'login', component: LoginComponent, pathMatch: 'full' }
];
export const appRoutes = [
{ path: '', redirectTo: '/events', pathMatch: 'full' },
{ path: 'user', loadChildren: './user/user.module#UserModule' }
];
您可以找到问题此处
这篇关于Angular 5 EmptyError:制作子路线时没有顺序排列的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!