Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

625
Visualizações
How can I change a selected TAB with [Previous], [Next] buttons using type script function

How can I switch tabs using previous and next buttons in angular type sript. Below I'm written some sample code, I don't know how to sync between buttons and tabs.

Sample code:

<div>
  <ng-container>
      <tabset>
        <tab>
          <ng-template tabHeading>
            <span title="Flash mobile">Flash</span>
          </ng-template>
          <p> Flashing mobile </p>
        </tab>
        <tab>
          <ng-template tabHeading>
            <span title="Restore mobile">Restore</span>
          </ng-template>
          <p> Restore mobile </p>
        </tab>
      </tabset>
    </ng-container>
 </div>

<div>
<button class="btn" (click)="updatePrev()"> Previous </button>
<button class="btn" (click)="updateNext()"> Next </button>
</div>
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

If you are using bootstrap tab, you can provide ids to your tabs. Reference your tabset component using template reference variable and use the select method to select the tabs by id. Refer the sample code below:

<ngb-tabset #t="ngbTabset">
  <ngb-tab id="tab-selectbyid1" title="Simple">
    <ng-template ngbTabContent>
      <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth
      master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh
      dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum
      iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
    </ng-template>
  </ngb-tab>
  <ngb-tab id="tab-selectbyid2">
    <ng-template ngbTabTitle><b>Fancy</b> title</ng-template>
    <ng-template ngbTabContent>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid.
      <p>Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table
      craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl
      cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia
      yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean
      shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero
      sint qui sapiente accusamus tattooed echo park.</p>
    </ng-template>
  </ngb-tab>
</ngb-tabset>

<p>
  <button class="btn btn-outline-primary" (click)="t.select('tab-selectbyid2')">Selected tab with "tab-selectbyid2" id</button>
</p>
over 4 years ago · Santiago Trujillo Relatório

0

Please check this solution as per your example, with some minor changes.

Change 1: Added Id's to each tabs. So that each Tabs will have unique id's

<tab>
   <ng-template tabHeading>
    <span title="Restore mobile">Restore</span>
   </ng-template>
   <p> Restore mobile </p>
</tab>

to

<tab id="1">
  <ng-template tabHeading>
    <span title="Restore mobile">Restore</span>
  </ng-template>
 <p> Restore mobile </p>
</tab>

During Next and previous operations, the IDs will be added/subtracted by one. The below Stackblitz sample with more than two tabs is self-explanatory. The sample is developed upon ngx-bootstrap.

https://stackblitz.com/edit/ngx-bootstrap-kdtihy?file=app%2Fapp.component.html

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda