Mukul_Vashistha
Mukul_Vashistha

Reputation: 106

How to get redirected to a particular tab in Angular 6?

There are 4 tabs on a particular URL and the first one is marked active by default. I want to get another tab in an active state on the occurrence of a particular event while getting redirected to this URL.

I've already tried solutions like:

  1. $('[href="#transaction_history"]').tab('show');

  2. $('.nav nav-pills nav-stacked a[href="#transaction_history"]').tab('show')

  3. $('.nav-stacked > .active').next('li').find('a').trigger('click');

  4. $('.nav-stacked li:eq(2) a').tab('show')

None of these have worked for me.

Upvotes: 0

Views: 280

Answers (1)

Sachin Shah
Sachin Shah

Reputation: 4533

You have to manage this via flag. and based on that you have apply class dynamically.

[ngClass]="{'active':tab == 'xtabName'}"

Upvotes: 1

Related Questions