简体   繁体   English

如何在模态窗口[ANGULAR 5]中创建路由?

[英]How to create routing inside a modal window [ ANGULAR 5 ]?

I have a requirement where i need to switch between 2 different views back and forth based on certain condition inside a modal window's body . 我有一个需要根据模态窗口的主体内的特定条件在2个不同的视图之间来回切换的要求。

Those 2 views are : 这两个视图是:

  1. List items (Initial view) 列表项(初始视图)
  2. Add new items 新增项目

After adding new items i need to switch to the List items view. 添加新项目后,我需要切换到“列出项目”视图。

NOTE: All these views should be displayed inside a modal windows body. 注意:所有这些视图都应显示在模式窗口主体中。

So using ANGULAR 5 routing how can i create new routes / sub routes inside this modal component ? 因此,使用ANGULAR 5路由时,如何在此模式组件内创建新的路由/子路由?

Create another router-outlet with a name like this 用这样的名称创建另一个路由器出口

<router-outlet name="modal"></router-outlet> 

To navigate to it in your ts, use 要在您的ts中导航到它,请使用

this.router.navigate([{ outlets: { modal: 'route' }}])

while in your html, use 在您的html中使用

<button md-button  [routerLink]="[{outlets: {'modal': ['route']}}]">Speakers</button>

you can also specify it in your routes like 您也可以在路线中指定它,例如

{ path: ':id', component: YourComponent, outlet: 'modal' }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM