我有一个角度应用程序,是加载懒惰模块。
首先,应用程序导航到home,在那里加载模块(名为module1):
主要路线:
const routes: Routes = [
{ path: "", redirectTo: "/home", pathMatch: "full" },
{ path: "home", loadChildren: "./module1/module1.module#Module1Module" },
];在module1 -还有路由表:
const routes: Routes = [
{
path: "", component: Home1Component,
children: [
{ path: 'bird', outlet: 'under', component: Home2Component }
]
}
];因此,由于它是懒洋洋地加载,所以当应用程序启动时,它会转到/home,在那里加载Home1Component
但是Home1Component也有一个按钮,它应该为出口路由设置一个值。
home1.component.html:
<input value="click to activate aux route" type="button" (click)="go()"/>
<router-outlet ></router-outlet>
<router-outlet name='under'></router-outlet> //<---- I want to activate only this这就是我试图激活出口路线的方式:
public go() {
this.router.navigate([{ outlets: { under: ['bird'] } }], { relativeTo: this.route })
}但我发现了一个错误:
错误:无法匹配任何路由。URL段:“home”
问题:
为什么我要得到这个错误,以及如何修复它?
发布于 2017-12-17 20:47:41
在@bug 5598的帮助下,他向我介绍了路由器的问题/错误。
延迟加载模块的默认空位置存在问题。
需要理解的关键是惰性模块不应该有空的根路径。
https://github.com/angular/angular/issues/10981#issuecomment-337162661:
https://stackoverflow.com/questions/47857150
复制相似问题