0
votes

I would like use layout tabs material with Angular:

https://material.angular.io/components/tabs/overview

I would like use auto click, how I do it ? how ask angular to click link "Tab1" wait 3 seconds and click"Tab2" in the loop.

1
please search for the javascript function setInterval()Ploppy
Thank's for response,wtimi
before use setInterval(), i search how i can automatic self click the link tap1 and tab2, I am noobe , in the jquery i know how dot it , but with material i did not how i can't do itwtimi
no problem, the issue you are facing is then quite simple, even if someone gave you the answer bellow, you should learn to read the api doc especially this part: material.angular.io/components/tabs/api#MatTabGroupPloppy

1 Answers

1
votes

You can bind to the selectedIndex property of the <mat-tab-group> like so:

html:

<mat-tab-group [(selectedIndex)]="selectedIndex">
  <mat-tab label="Tab 1">Content 1</mat-tab>
  <mat-tab label="Tab 2">Content 2</mat-tab>
</mat-tab-group>

component:

selectedIndex = 0;
...

    ngOnInit() {
        setTimeout(() => {
            this.selectNextTab();
        }, 3000);
    }

    selectNextTab() {
        this.selectedIndex++;
    }
...