Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!