Search code examples
angulartypescriptangular2-routingangular5vmware-clarity

display first tab as default when page loads


log.component.html:

<clr-tabs>
<clr-tab>
    <button style="margin-left: 3% !important;" clrTabLink [routerLink]="'log1'">Log1</button>
    <ng-template [(clrIfActive)]="log1">
        <clr-tab-content>
            <div class="main-container">
                <div class="content-container">
                    <div class="content-area">
                        <router-outlet></router-outlet>
                    </div>
                </div>
            </div>
        </clr-tab-content>
    </ng-template>
</clr-tab>
<clr-tab>
    <button style="margin-left: 3% !important;" clrTabLink [routerLink]="'log2'">Log2</button>
    <ng-template [(clrIfActive)]="log2">
        <clr-tab-content>
            <div class="main-container">
                <div class="content-container">
                    <div class="content-area">
                        <router-outlet></router-outlet>
                    </div>
                </div>
            </div>
        </clr-tab-content>
    </ng-template>
</clr-tab>

route.module.ts:

 { path: 'log', component: LogComponent, children: [
    { path: 'log1', component: Log1Component },
    { path: 'log2', component: Log2Component ,pathMatch: 'full' }
   ]
 }

I want to load log1 tab content as default when user hits /log,how to approach this functionality,any pointers will be useful for a beginner like me.

currently while clicking on log1,it displays both tabs and when i click on first tab it displays the content of tab1,i need this tab1 data display as default


Solution

  • Does that work?

     { path: 'log', component: LogComponent, children: [
        { path: '', component: Log1Component },
        { path: 'log1', component: Log1Component },
        { path: 'log2', component: Log2Component ,pathMatch: 'full' }
       ]
     }