Bird
0
0

Identify the error in this Angular template:

medium📝 Debug Q6 of 15
Angular - Templates and Data Binding
Identify the error in this Angular template:
<button [disabled]="isDisabled">Submit</button>

Component code:
isDisabled = 'false';
ANo error, button will be enabled
BSyntax error in template binding
CButton will always be disabled regardless of isDisabled
DError because isDisabled should be boolean, not string
Step-by-Step Solution
Solution:
  1. Step 1: Check the type of isDisabled

    The property isDisabled is a string 'false', not a boolean false.
  2. Step 2: Understand property binding behavior

    Property binding expects a boolean for disabled. A string 'false' is truthy, so the button will be disabled unexpectedly.
  3. Final Answer:

    Error because isDisabled should be boolean, not string -> Option D
  4. Quick Check:

    Boolean needed for disabled property [OK]
Quick Trick: Use boolean values for property bindings like [disabled] [OK]
Common Mistakes:
  • Using string 'false' instead of boolean false
  • Assuming string 'false' disables the button
  • Ignoring type mismatch warnings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes