【问题标题】:Navigation from auxiliary route to another child routeNavigation from auxiliary route to another child route
【发布时间】:2022-12-01 14:39:08
【问题描述】:

I have routes:

const routes: Routes = [
   {path: 'all', component: NodepadComponent, children: [
      {path: 'create', component: NotepadCreateComponent},
      {path: 'note/:id', component: NotepadItemComponent, outlet: 'item'}]
 }];

I want to navigate from "item" route to "create" route.

I tried this:

constructor(
private route: ActivatedRoute,
private router: Router,
){ }

this.router.navigate(['create', {outlets: {item: null}}], 
{relativeTo: this.route.parent });

But result is(/all/(create//item:note/1)

How to remove "item" route and navigate only create route? Thanks

【问题讨论】:

    标签: angular router angular-auxiliary-routes


    【解决方案1】:
    this.router.navigate(['create']).then(() => this.router.navigate([{outlets: {item: null}}]));
    

    Named routes' router state is stored separately from the primary outlet state. There isn't a way to navigate from one to another at once.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-20
      • 2022-12-01
      • 1970-01-01
      • 2022-12-01
      • 2014-09-25
      • 1970-01-01
      • 1970-01-01
      • 2020-02-01
      相关资源
      最近更新 更多