Bird
0
0

Identify the error in this Angular template snippet:

medium📝 Debug Q14 of 15
Angular - Internationalization and Accessibility
Identify the error in this Angular template snippet:
<div role="button" [aria-checked]="isChecked">Click me</div>

Assuming isChecked is a boolean in the component.
ARole attribute cannot be 'button' on a div
BBoolean cannot be bound to ARIA attributes
CIncorrect binding syntax; should use [attr.aria-checked]
DMissing closing tag for div
Step-by-Step Solution
Solution:
  1. Step 1: Check ARIA attribute binding syntax

    ARIA attributes are not DOM properties, so binding must use [attr.aria-checked] instead of [aria-checked].
  2. Step 2: Verify role and HTML correctness

    Using role="button" on a div is valid for accessibility. The div tag is properly closed.
  3. Final Answer:

    Incorrect binding syntax; should use [attr.aria-checked] -> Option C
  4. Quick Check:

    Use [attr.aria-...] for ARIA binding [OK]
Quick Trick: Always use [attr.aria-...] for ARIA bindings, not direct property [OK]
Common Mistakes:
  • Binding ARIA attributes without attr prefix
  • Thinking role="button" is invalid on div
  • Confusing boolean binding rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes