Why Event Emitter can't use in service in angular 6?
In Angular documentation they mentioned, "Use in directives and components to emit custom events"
Why Event Emitter can't use in service in angular 6?
In Angular documentation they mentioned, "Use in directives and components to emit custom events"
Because in services all waht you have to do is manipulating data, if you want to notify the data changes you can use Subjet
or BehaviorSubjet
. EventEmitter is generally used to notify changes from child to parent and as said is supposed to be used only for @Output
.
please take a look at this link