[英]How do I create a shared data object between two angular components with updates
I want to create a queue of objects which is shared between two components in the same module.我想创建一个对象队列,该队列在同一模块中的两个组件之间共享。 Also, as soon as there are new objects inserted or deleted from the queue, the changes should reflect in both the components.此外,只要有新对象从队列中插入或删除,更改就应反映在两个组件中。
I will push or pop from the queue using buttons and associated functions in both of those components.我将使用这两个组件中的按钮和相关功能从队列中推送或弹出。
How do I achieve this?我如何实现这一目标?
Angular 9
NodeJS 12.18
service
to the module (both component will be able to inject)向模块添加service
(两个组件都可以注入)RxJs
queue and expose it (or a subset of it) as the service API使用RxJs
队列并将其(或其子集)公开为服务 API
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.