简体   繁体   English

带有 Bootstrap 动态标签导航的 Angular 应用

[英]Angular App with Bootstrap Dynamic Tabs Navigation

I'm trying to create a SPA with Angular and Bootstrap.我正在尝试使用 Angular 和 Bootstrap 创建一个 SPA。 I have a menu with links.我有一个带链接的菜单。 When the user clicks the link, the new Bootstrap Dynamic Tab opens and it's content is .当用户单击链接时,新的 Bootstrap 动态选项卡将打开,其内容为 . Now, i want to add some navigation INSIDE the tab.现在,我想在选项卡内添加一些导航。 For example:例如:

I have a Sale-Register Component.我有一个销售注册组件。 Inside it i have four links to other components.在它里面,我有四个指向其他组件的链接。 I want to open the links location (eg. routerLink='path_to_component') INSIDE the same bootstrap tab's content.我想在相同的引导程序选项卡的内容中打开链接位置(例如 routerLink='path_to_component')。

Any solutions how to achieve it?任何解决方案如何实现它?

I think you want to use Multiple Router Outlets for this.我认为您想为此使用多个路由器插座

You need add a named router outlet to your Sale-Register Component like:您需要将一个命名的路由器插座添加到您的销售注册组件中,例如:

<router-outlet name='outletname'></router-outlet>

Then you also need to define which component to load in your Routes array like:然后,您还需要定义要在 Routes 数组中加载的组件,例如:

const routes: Routes = [
  { path: "page", component: PageComponent }, // This is your primary outlet's definition
  {
    path: "tabpage",
    component: TabPageComponent,
    outlet: "outletname" // This is where you define which outlet to use
  }
]

Finally update the navigation link to use your outlet:最后更新导航链接以使用您的插座:

<a [routerLink]="[{ outlets: { primary: ['page'], outletname: ['tabpage'] } }]">
  Link to the tab
</a>

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

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