The @Output() 's type. Tells Angular to create a new event emitter and that the data it emits is of type string. For more information on EventEmitter , see the EventEmitter API documentation. The addNewItem() function uses the @Output() , newItemEvent , to raise an event with the value the user types into the <input> .
To make your code work in a stackblitz, I had to replace
import { EventEmitter } from 'events';
with
import { EventEmitter } from '@angular/core';
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();
In your component just use core angular module. Simply put this code at beginning of file.
import { EventEmitter } from '@angular/core';
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With