There are three ways to achieve this.
1 - The easiest way to do this is to use the boot tabs: Bootstrap docs
<ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#tab1" (click)="DoSomeActionForTab1()">tab1</a></li> <li><a data-toggle="tab" href="#tab2" (click)="DoSomeActionForTab2()">tab2</a></li> </ul> <div class="tab-content"> <div id="tab1" class="tab-pane fade in active"> <h3>Tab1</h3> <p>Some content.</p> </div> <div id="tab2" class="tab-pane fade"> <h3>Tab2</h3> <p>Some content in menu 1.</p> </div> </div>
1 - You can do this through named routers, which are slightly more advanced: Documents
HTML
<div class="panel-body"> <div class="wizard"> <a [routerLink]="[{ outlets: { tabs: ['tab1'] } }]" routerLinkActive="active">Tab1</a> <a [routerLink]="[{ outlets: { tabs: ['tab2'] } }]" routerLinkActive="active">Tab2</a> </div> <router-outlet name="tabs"></router-outlet> </div>
Routing module
{ path: 'tab1', component: Tab1Component, outlet: 'tabs' }, { path: 'tab2', component: Tab2Component, outlet: 'tabs' }
3 - There is also an npm package for tabs: an npm package
Wesley coetzee
source share