How to get the active tab In Angular Material2

后端 未结 4 386
不思量自难忘°
不思量自难忘° 2020-12-05 02:13

I want to get which tab is active. I tried to use a @ViewChild decorator and accessing the element properties that way, but it returns null.

<
4条回答
  •  我在风中等你
    2020-12-05 02:41

    This is how you can get active index of active angular material tabs

    .html file

    .ts file

    logChange(index)
    {
      console.log(index);
    } 
    

    Don't forget to add import in app.module.ts file

    import { MatTabsModule } from '@angular/material/tabs';

提交回复
热议问题