I simply redirected to Profile page with router fragment (/profile#favorites) where favorite is a Bootstrap tab component. By default, first tab is active and favorite tab is 2 here in my case which I want to programmatically activate retriving fragment name from the url.
I got the fragment from url by:
this.activatedRoute.fragment.subscribe(fragment => {
console.log('fragment : ', fragment);
});
My tabs structure is :
<ul class="nav nav-tabs">
<li class="active"> <a data-toggle="tab" href="#myPets"> My Pets</a> </li>
<li><a data-toggle="tab" href="#favorites">Favorites</a></li>
<li *ngIf="!userDetails?.isSocialSiteUser">
<a data-toggle="tab" href="#changePassword">Change Password</a>
</li>
<!-- <li><a data-toggle="tab" href="#account"> Account</a></li> -->
<li> <a data-toggle="tab" href="#meets">Upcoming Meet and Greets</a> </li>
<li> <a data-toggle="tab" href="#myDeals" *ngIf="myDeals.length">My Deals</a> </li>
</ul>
<div class="tab-content">
<div id="myPets" class="tab-pane overflow-y-500-x-hide fade in active" #myPets>
...
</div>
<div id="favorites" class="overflow-y-500-x-hide tab-pane fade" #favorites>
<sfl-profile-favorites></sfl-profile-favorites>
</div>
...
</div>
Now I don't know how to activate the favorites tab. Maybe this can be achieved by toggling the in active class, but how can I remove from all other tabs and add to particular tab?