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

220
Visualizações
How to show or hide the data based on dropdown selection

In my angular application I have a dropdown list and below that some data is in div.

component.html

<select class="form-control" id="power" required>
  <option value="" disabled selected>Select a category</option>
  <option *ngFor="let category of categoryNames">{{ category }}</option>
</select>

<!--below code I have to show or hide-->

<div class="row">
  <div class="col-sm-8">
    <p>Slect Habits</p>
    <h5 class="formxp">Slect Items</h5>
  </div>
  <div class="col-sm-4">
    <p>Slect Habits</p>
    <h5 class="formxp">Slect Items</h5>
  </div>
</div>

So my requirement is when I click on any of the items from the dropdown list I have to show the div (after the dropdown in above code)

Can anyone help me regarding the same.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can define a template variable (e.g. #mySelect) on the <select> element, then use it to determine the selected value: mySelect.value.

In case you need to display the div if the selected category equals to 'Habit', you can try the following:

<!-- #mySelect is declared on <select> element -->
<select class="form-control" id="power" required #mySelect>
  <option value="" disabled selected>Select a category</option>
  <option *ngFor="let category of categoryNames">{{ category }}</option>
</select>

<div class="row" *ngIf="mySelect.value === 'Habits'">
  <div class="col-sm-8">
    <p>Slect Habits</p>
    <h5 class="formxp">Slect Items</h5>
  </div>
  <div class="col-sm-4">
    <p>Slect Habits</p>
    <h5 class="formxp">Slect Items</h5>
  </div>
</div>

You can read more about the Angular Template Variable here: https://angular.io/guide/template-reference-variables

about 4 years ago · Juan Pablo Isaza 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