Use of EventEmitter in service of Angular6

廉价感情. 提交于 2021-01-28 06:43:08

问题


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"


回答1:


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



来源:https://stackoverflow.com/questions/52109509/use-of-eventemitter-in-service-of-angular6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!