angulartabsnebularnebula

Run event in Nebular's NbTabset in Angular 2


How could I execute an event in NbTabset in nebular from angular 2

in the documentation that is not detailed, I would appreciate your help, whether or not that can execute a function in the NbTabset

<nb-card>
  <nb-card-body>

    <nb-tabset>
      <nb-tab tabTitle="Mujeres" (click)="onEvento()">
        <p>Aquí lógica de Mujeres </p>
      </nb-tab>
      <nb-tab tabTitle="Varones" (click)="onEvento()">
        <p>Aquí lógica de varones </p>
      </nb-tab>
    </nb-tabset>

  </nb-card-body>
</nb-card>

Solution

  • Yes,its possible to emit changeTab event NbTabset in nebular.Below is the code snippet and a sample stackblitz example

      <nb-card>
      <nb-card-body>
        <nb-tabset  (changeTab)="onEvento($event)">
          <nb-tab tabTitle="Mujeres">
          <div>
            <p>Aquí lógica de Mujeres </p>
            </div>
          </nb-tab>
          <nb-tab tabTitle="Varones">
            <p>Aquí lógica de varones </p>
          </nb-tab>
        </nb-tabset>
      </nb-card-body>
    </nb-card>
    

    In component

    onEvento(e){
        console.log(e.tabTitle)
      }