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

160
Vistas
Get element by classname from one component for use in another component using Angular

I have a background image on a component however in another component when an item is clicked, I would like for the background image in the other component to shrink. The component is current not being picked up

Bg.html (The component with the background I'd like to shorten)

 <section ngClass="main-bg">
  </section>

box.component.ts (The component where I'd like to shorten the bg)

  export class BoxComponent implements OnInit {
     
    main: any;

  }

  ngOnInit(): void {
    this.main = (this.ElByClassName.nativeElement).querySelector('.main-bg');
  }




    ShortedBg()
    {
      if (this.main != null) {
          this.main.style.height = "31vh";
          console.log("section picked up");
        }
        else {
          console.log("section not picked up");
        }
    }
about 4 years ago · Juan Pablo Isaza
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