Bird
0
0

Consider this Angular template snippet:

medium📝 Predict Output Q4 of 15
Angular - Internationalization and Accessibility
Consider this Angular template snippet:
<input type="checkbox" [attr.aria-checked]="isSelected ? 'true' : 'false'" />

If isSelected is false, what will be the value of the aria-checked attribute in the rendered HTML?
A"false"
B"true"
Cfalse (boolean)
Dnull (attribute removed)
Step-by-Step Solution
Solution:
  1. Step 1: Understand binding

    The attribute aria-checked is bound using Angular's property binding with a ternary expression.
  2. Step 2: Evaluate expression

    If isSelected is false, the expression isSelected ? 'true' : 'false' evaluates to 'false' (string).
  3. Step 3: Rendered attribute

    The attribute aria-checked will be set to the string value "false" in the HTML.
  4. Final Answer:

    "false" -> Option A
  5. Quick Check:

    Boolean false is converted to string 'false' in attribute binding [OK]
Quick Trick: Boolean values in attribute bindings become strings [OK]
Common Mistakes:
  • Assuming boolean false removes the attribute
  • Confusing boolean false with string 'false'
  • Expecting attribute to be boolean false

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes