所有人。我有@angular/router的问题。我有我的应用程序的路由配置。
Router [] = [
{
path: 'main',
component: MainComponent,
children: [
{
path: 'info',
component: InfoComponent
}
]
}我有下一个流程:我进入页面,它导航到MainComponent,这只是从DB获得对象。在MainComponent中,我使用this.router.navigate(['info'], {relativeTo: this.route})。在InfoComponent中,我有依赖于来自MainComponent的父级的componentResolver
export class InfoComponent extends OnInit {
constructor (@Host() private parent: MainComponent) {}
...
ngOnInit () { `componentResolver is done` }
}问题是,当我通过Chrome导航栏中的后退按钮或点击Alt+<返回时,它只显示空视图(MainComponent)。我的问题在哪里?为什么会发生这种情况?
发布于 2017-08-07 15:10:58
尝试此路由器配置,而不是在MainComponent中手动导航(因此删除this.router.navigate(['info'], {relativeTo: this.route}) ):
Router [] = [
{
path: 'main',
component: MainComponent,
children: [
{
path: '',
redirectTo: 'info',
pathMatch: 'full'
},
{
path: 'info',
component: InfoComponent
}
]
}https://stackoverflow.com/questions/45540814
复制相似问题