You are tasked with creating a directive that changes the background color of an element when it's hovered over. Which type of directive would be best suited for this task?

  • Attribute Directive
  • Component Directive
  • Service Directive
  • Structural Directive
For changing the background color of an element when hovered, an Attribute Directive is the best choice. Attribute Directives are used to modify the behavior or appearance of an element. You can create an Attribute Directive that listens for the mouseenter and mouseleave events and modifies the element's style accordingly. This approach is more suitable than other types of directives for this specific task.
Add your answer
Loading...

Leave a comment

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