Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activate a Nebular Theme tab

I am using the Nebular Theme component and will want to manually activate a particular tab with a button click. I can't find any information in their doc https://akveo.github.io/nebular/docs/components/tabs/overview#nbtabsetcomponent

<nb-tabset>
  <nb-tab tabTitle="Search">xxxx</ng-tab>
  <nb-tab tabTitle="Add">yyyyy</ng-tab>
</nb-tabset>

<button (click)="ActivateTabAdd()">Add</button>

Any help appreciated. Thanks

like image 277
Raymond Tey Avatar asked Jan 02 '23 16:01

Raymond Tey


2 Answers

Yes why not

there is an active attribute for tab nb-tab which Specifies active tab

so you can handle this like

<nb-tabset>
  <nb-tab tabTitle="Search" active="{{setActiveSearch}}">xxxx</ng-tab>
  <nb-tab tabTitle="Add" active="{{setActiveAdd}}" >yyyyy</ng-tab>
</nb-tabset>
<button (click)="ActivateTabAdd()">Add</button>

and in TS file

setActiveSearch : boolean = false;
setActiveAdd: boolean = false;

ActivateTabAdd(){
this.setActiveAdd = true;
}
like image 109
Hrishikesh Kale Avatar answered Jan 15 '23 23:01

Hrishikesh Kale


<nb-tabset id="tabset" name="tabset" #tabset>
  <nb-tab tabTitle="Search" id="searchTab" name="searchTab" #searchTab >xxxx</ng-tab>
  <nb-tab tabTitle="Add" id="addTab" name="addTab" #addTab >yyyyy</ng-tab>
</nb-tabset>
<button (click)="ActivateTabAdd()">Add</button>
import { NbTabsetComponent, NbTabComponent } from '@nebular/theme/components/tabset/tabset.component';

@ViewChild("tabset") tabsetEl: NbTabsetComponent;
@ViewChild("addTab") addTabEl: NbTabComponent;

ActivateTabAdd(){
  this.tabsetEl.selectTab(this.addTabEl);
}

like image 32
Zeeshan Khatri Avatar answered Jan 16 '23 01:01

Zeeshan Khatri