Bird
0
0

Identify the error in this Angular component property declaration:

medium📝 Debug Q6 of 15
Angular - TypeScript in Angular
Identify the error in this Angular component property declaration:
export class DemoComponent {
  isActive: boolean = 'yes';
}
AMissing semicolon after property declaration
BProperty name cannot start with 'is'
CBoolean type should be uppercase Boolean
DAssigning string 'yes' to a boolean property
Step-by-Step Solution
Solution:
  1. Step 1: Check type annotation and assigned value

    The property isActive is typed as boolean but assigned a string 'yes'.
  2. Step 2: Understand TypeScript type rules

    Assigning a string to a boolean property causes a type error.
  3. Final Answer:

    Assigning string 'yes' to a boolean property -> Option D
  4. Quick Check:

    Type mismatch in assignment = Assigning string to boolean [OK]
Quick Trick: Boolean properties must be true or false, not strings [OK]
Common Mistakes:
  • Using uppercase Boolean instead of boolean
  • Ignoring type mismatch errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes