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

175
Views
Highlight Side Nav on Scroll in angular

I want to make my Side Nav change its color when I scroll down my page in angular I know about host listeners but I'm not getting the idea of how I can implement them in my project.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Sure host listeners is one way to listen for scroll events.

  @HostListener('window:scroll', ['$event'])
  onWindowScroll($event) {
      console.log("scrolling...");
  }

But maybe you want to listen for something specific?

    <div #element (scroll)="onScroll(element)">

You could then use [NgStyle] to give your sidenav a color based on some value?

 myColor = 'red';

 onScroll(element) {
  console.log("scrolling...");
  console.log(element.scrollTop)

  if (element.scrollTop > 100) {
    this.myColor = 'blue';
  }
  
 }
[ngStyle]="{'background-color': myColor }"
about 4 years ago · Juan Pablo Isaza Report
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!