首页 文章

如何在命名插座是未命名插座的子节点时导航到路线

提问于
浏览
1

我正在使用Angular 5.我在app.component中有一个 . 我动态路由到特定组件,例如“仪表板” . 此仪表板组件具有命名的路由器插座和一组子组件 . 现在我必须通过路由器导航从仪表板组件更改指定路由器插座的内容 . 我试过以下导航

1. this.router.navigate([{ outlets: { right: 'temp1' }}], {redirectTo: this.activatedRoute})
2. this.router.navigate(['/dashboard',{ outlets: { right: 'temp1' }}])

但两者都失败并且跟随错误

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'dashboard'

虽然我正在更改浏览器网址然后其工作但无法通过导航加载 . 我认为这是因为父母 . 任何帮助,将不胜感激 .

1 回答

  • 1

    你的app.router是怎么样的?在呼叫路线时,您获得的网址是多少?我努力了解routerlink中的相对路由 . 在两天的时间里,我可以发送你对我有用的东西,但是远离我的电脑 .

    如果相对地址错误,你可以使用../dashboard去一个目录 . 或者,如果您使用相同名称的路由,则可能需要确保并在app.routing中将所需的pathMatch设置为full .

    this.router.navigate([{outlets:{right:['dashboard','temp']}}]);这样的事情应该有效 .

    https://www.concretepage.com/angular-2/angular-2-4-named-router-outlet-popup-example

相关问题