Bird
0
0

Which is the correct syntax to bind the ARIA attribute aria-checked to a component property isChecked in an Angular template?

easy📝 Syntax Q3 of 15
Angular - Internationalization and Accessibility
Which is the correct syntax to bind the ARIA attribute aria-checked to a component property isChecked in an Angular template?
A<button bind-aria-checked="isChecked">Check</button>
B<button aria-checked="{{isChecked}}">Check</button>
C<button [aria-checked]="isChecked">Check</button>
D<button [attr.aria-checked]="isChecked">Check</button>
Step-by-Step Solution
Solution:
  1. Step 1: Understand Angular binding for ARIA attributes

    ARIA attributes must be bound using [attr.aria-...] syntax to bind to DOM attributes.

  2. Step 2: Identify the correct syntax

    <button [attr.aria-checked]="isChecked">Check</button> uses [attr.aria-checked] which is correct. <button aria-checked="{{isChecked}}">Check</button> uses interpolation which is not recommended for ARIA attributes. <button [aria-checked]="isChecked">Check</button> misses attr. prefix. <button bind-aria-checked="isChecked">Check</button> uses invalid syntax.

  3. Final Answer:

    <button [attr.aria-checked]="isChecked">Check</button> -> Option D
  4. Quick Check:

    Bind ARIA with [attr.aria-*] syntax [OK]
Quick Trick: Use [attr.aria-*] to bind ARIA attributes dynamically [OK]
Common Mistakes:
  • Omitting 'attr.' prefix in binding
  • Using interpolation {{}} inside ARIA attributes
  • Using invalid bind- syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes