Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
Angular swap between 2 different class on click

I am trying to build a toolbar with search functions in angular. For example : enter image description here

and this divisions are like:

<div class="toolbar">
    <div class="search">search field</div>
    <div class="otherElements">
      <div class="search-btn"><button>search</button></div>
      <div class="bookmark">bookmark_icon</div>
      <div class="otherIcons">other icons</div>
    </div>
</div>

Here the .search will remain hidden. If i click on search-btn then .search will show up which will cover the whole toolbar. I can hide the div on button click by using [hidden] but the problem is .search doesn't cover the whole place. Now it is something like : enter image description here

if I click the search button : enter image description here

what I want is : enter image description here I want the search bar cover the whole .toolbar if search button is pressed.

I have less knowledge of css

Here is a minimal example

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try using Angular ngIf instead of using css classes when trying to show or hide elements depending on some condition, like this:

<div class="toolbar">
<div class="search" *ngIf="!searchItem">search field</div>
<div class="otherElements" *ngIf="searchItem">
  <div class="search-btn"><button>search</button></div>
  <div class="bookmark">bookmark_icon</div>
  <div class="otherIcons">other icons</div>
</div>

In your example, you would also have to put a width 100% on the .input element to make it cover the whole site, like this:

input: { width: 100% }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda