You need to create a custom directive that changes the background color of an element when the user hovers over it. What Angular concepts and decorators would you use to achieve this?

  • Apply styles directly in the component's HTML template
  • Implement ngOnChanges to track changes in the element's state
  • Use @HostListener to handle hover events
  • Utilize @ViewChild to access the element and manipulate its styles
To create a custom directive that changes the background color on hover, you would use the @HostListener decorator to handle hover events and apply the desired behavior.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *