Bird
0
0

How do you correctly declare an @Output property named update that emits boolean values in Angular?

easy📝 Conceptual Q2 of 15
Angular - Component Interaction
How do you correctly declare an @Output property named update that emits boolean values in Angular?
A@Output() update = new EventEmitter<boolean>();
B@Output update: EventEmitter = new EventEmitter();
C@Output() update: boolean = new EventEmitter();
D@Output() update = EventEmitter<boolean>;
Step-by-Step Solution
Solution:
  1. Step 1: Syntax for @Output

    The correct syntax uses @Output() decorator followed by property initialization with new EventEmitter<type>().
  2. Step 2: Type specification

    Here, the event emits boolean values, so EventEmitter<boolean> is used.
  3. Final Answer:

    @Output() update = new EventEmitter<boolean>(); -> Option A
  4. Quick Check:

    Decorator with parentheses and new EventEmitter instance [OK]
Quick Trick: Always initialize @Output with new EventEmitter() [OK]
Common Mistakes:
  • Omitting parentheses after @Output
  • Not initializing EventEmitter with new
  • Incorrect type annotation or missing generic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes