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.
Loading...
Related Quiz
- When the ViewEncapsulation.Emulated mode is used, Angular adds unique ________ to styles to achieve scoped styling.
- To ensure high performance when dealing with large datasets in Angular, one should avoid data ________ and instead use immutable operations.
- The HostListener decorator in custom directives listens to ________ events.
- The HttpClient method used to send data to the server as a POST request is ________.
- For a directive to modify the value of a host property, you would use the ______ decorator.