Bird
0
0

You want to create a reusable directive that changes text color based on a condition. Which approach best explains why directives are needed here?

hard📝 Application Q15 of 15
Angular - Directives
You want to create a reusable directive that changes text color based on a condition. Which approach best explains why directives are needed here?
ADirectives replace components for UI layout
BDirectives let you add reusable behavior to any HTML element without changing its structure
CDirectives are only for creating new HTML tags, not for behavior
DDirectives are used to fetch data from servers
Step-by-Step Solution
Solution:
  1. Step 1: Identify directive purpose in reuse

    Directives add behavior like changing text color reusable on any element without altering HTML structure.
  2. Step 2: Eliminate incorrect uses

    Directives do more than create tags, do not replace components, and do not fetch data.
  3. Final Answer:

    Directives let you add reusable behavior to any HTML element without changing its structure -> Option B
  4. Quick Check:

    Directives add reusable behavior = C [OK]
Quick Trick: Directives add behavior reuse without new tags or data fetching [OK]
Common Mistakes:
  • Thinking directives only create new tags
  • Confusing directives with components
  • Assuming directives handle data fetching

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes