Click listener when tab is clicked - angular2 and ng bootstrap
The below should work correctly every time.
fetchNews(evt: any) {
console.log(evt); // has nextId that you can check to invoke the desired function
}
<ngb-tabset (tabChange)="fetchNews($event)">
<ngb-tab title="Active">
<ng-template ngbTabContent>
<table class="table table-sm table-striped">
...
</table>
</ng-template>
</ngb-tab>
</ngb-tabset>
You can declare ngbTabTitle
template and catch click event there:
<ngb-tab>
<ng-template ngbTabTitle>
<div (click)="fetchNews('active')">Active</div>
</ng-template>
<ng-template ngbTabContent>
<table class="table table-sm table-striped" (click)="fetchNews('active')">
...
</table>
</ng-template>
<ngb-tab>