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

163
Visualizações
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 à 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