Topic: On tab click change url with hashtag

maticdiba pro asked 5 years ago


I am using tabs component on one of my pages. I would like to achieve that by clicking on one of the tabs url would change from something like this: /user/321 to this: /user/321#friendlist

By this I would like to achieve that by following link: /user/321#friendlist, list of friends tab would be selected. Is there a tutorial that would help me achieve that?

maticdiba pro answered 5 years ago

Thank you for your answer. I tried this approach, but when I try to use the parameter and programatically set active tab with:

this.staticTabs.setActiveTab(selectedTab > 0 ? selectedTab : 0);
I get error that staticTabs is undefined. I call this command in ngOnInit. I declare staticTabs like this:
@ViewChild('staticTabs') staticTabs: TabsetComponent;
SelectedTab variable is retrieved from router.queryParams and holds a valid number (tested).
If I try to set it with button command it works. I'm not sure where the problem is. 

Arkadiusz Idzikowski staff commented 5 years ago

You need to call this method in ngAfterViewInit hook.

maticdiba pro commented 5 years ago

That worked. I was sure that I used it in ngInit before. Thank you for your help.


Damian Gemza staff answered 5 years ago

Dear @maticdiba 

You have to search the Internet for some tutorials because your question is not directly related to the MDB but to the Angular itself.

Please check this link. Maybe this will answer your question.

Best Regards,


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: 7.0.0
  • Device: computer
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No