An error occurred: @Output not initialized
I had also the same error. I found that Auto Import extension of VS Code did this. import * as EventEmitter from 'events';
is imported instead of import { EventEmitter } from '@angular/core';
So make sure if the import is ok or not.
I had the same problem even importing from @angular/core
.
The problem: I was initializing the EventEmmitter
object in the ngOnInit
method from my component class.
Solution: I moved the initialization to the component's class constructor.
Had the same error,
Import was correct like
import { EventEmitter } from '@angular/core';
But the variable definition was wrong:
@Output() onFormChange: EventEmitter<any>;
Should be:
@Output() onFormChange: EventEmitter<any> = new EventEmitter();
To make your code work in a stackblitz, I had to replace
import { EventEmitter } from 'events';
with
import { EventEmitter } from '@angular/core';