Topic: MdbTabsComponent setActiveTab not working

tech pro asked 2 years ago

I am using angular mdbtabs with latest version 5.

I am generating the tabs using nfFor as the tabs are dynamic. The active tab is not set ever after i am setting on the ts file

ngOnInit(): void { = true

} ngAfterViewInit(): void { = true this.tabs.setActiveTab(1) }

noveltytech priority answered 3 weeks ago

Is this fixed? I still can't manually set the active tab. I am on Angular 17 MDB5 v6

Rafał Seifert staff commented 3 weeks ago

Please refer to our API section in official docs. We have example for using setActiveTab method:

shellxsoftware free answered 9 months ago

same issue here, any fix?

Arkadiusz Idzikowski staff answered 2 years ago

Please try to use this code as a workaround for now, we will take a closer look at that to check if we can change something in the component code to fix that:

  ngAfterViewInit() {
    Promise.resolve().then(() => {

Lumpenstein free commented 10 months ago


I am facing a similar bug when trying to set the last active tab index (read from localstorage). When the Tab component gets mounted it is triggering the onTabChange event with the index of the first tab, is there a way to prevent this? (a property like 'triggeredByUser' would suffice as well).

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: MDB5 2.0.0
  • Device: PC
  • Browser: chrome
  • OS: Windowns
  • Provided sample code: No
  • Provided link: No