Bird
0
0

Which of the following is the correct syntax to declare an @Output property named notify using EventEmitter in Angular?

easy📝 Syntax Q12 of 15
Angular - Component Interaction
Which of the following is the correct syntax to declare an @Output property named notify using EventEmitter in Angular?
A@Output() notify = new EventEmitter;
B@Output notify = EventEmitter<string>();
C@Output() notify = new EventEmitter<string>();
D@Output() notify: EventEmitter<string> = EventEmitter();
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct EventEmitter syntax

    The correct way is to use @Output() decorator with a property initialized as new EventEmitter<type>().
  2. Step 2: Check each option

    @Output() notify = new EventEmitter(); correctly uses parentheses after @Output and calls new EventEmitter<string>(). Others miss parentheses or use wrong initialization.
  3. Final Answer:

    @Output() notify = new EventEmitter(); -> Option C
  4. Quick Check:

    Use @Output() with new EventEmitter() [OK]
Quick Trick: Always use parentheses: @Output() and new EventEmitter() [OK]
Common Mistakes:
  • Omitting parentheses after @Output
  • Not using 'new' keyword with EventEmitter
  • Incorrect property type declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes