Components: How to set particular tab active ?

Created on 6 Mar 2018  路  4Comments  路  Source: angular/components

I want to set a particular tab active by default.
I have tried this but it is not working.

<mat-tab-group class="m-t-30" [(selectedIndex)]="selectedIndex">
    <mat-tab label="{{wf.ApproverName}}" *ngFor="let wf of workflow_list">
    </mat-tab>
</mat-tab-group>

Most helpful comment

@Input()selectedIndex: number | null: The index of the active tab. 聽

SelectedIndex expects a number binding as property, so you can select any tab starting from 0 to (workflow_list.length - 1)

<mat-tab-group class="m-t-30" [selectedIndex]="2">
    <mat-tab label="{{wf.ApproverName}}" *ngFor="let wf of workflow_list">
    </mat-tab>
</mat-tab-group>

All 4 comments

Please keep GitHub issues for bug reports / feature requests. Better avenues for troubleshooting / questions are stack overflow, gitter, mailing list, etc.

@Input()selectedIndex: number | null: The index of the active tab. 聽

SelectedIndex expects a number binding as property, so you can select any tab starting from 0 to (workflow_list.length - 1)

<mat-tab-group class="m-t-30" [selectedIndex]="2">
    <mat-tab label="{{wf.ApproverName}}" *ngFor="let wf of workflow_list">
    </mat-tab>
</mat-tab-group>

@camilogiraldo is correct. Closing as a non-issue.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings