MdbTabsComponent setActiveTab not working


Topic: MdbTabsComponent setActiveTab not working

tech pro asked 3 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 {

this.tabs.tabs.first.active = true
this.tabs.setActiveTab(1)

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


Arkadiusz Idzikowski staff answered 3 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(() => {
      this.tabs.setActiveTab(1);
    });
  }

Lumpenstein commented a year ago

Hello,

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).


same issue here, any fix?


noveltytech pro premium priority answered 7 months ago

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


Rafał Seifert commented 7 months ago

Please refer to our API section in official docs. We have example for using setActiveTab method: https://mdbootstrap.com/docs/angular/navigation/tabs/#api-section-methods


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue
  • User: 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
Tags