简体   繁体   English

如何在两个带有更新的角度组件之间创建共享数据对象

[英]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
  1. Add a service to the module (both component will be able to inject)向模块添加service (两个组件都可以注入)
  2. Use RxJs queue and expose it (or a subset of it) as the service API使用RxJs队列并将其(或其子集)公开为服务 API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将来自两个组件的数据存储在单个对象/状态中? - How do I store data from two components in a single object/state? 如何在 Angular 中使用第三方库动态创建组件? - How do I dynamically create components with third party library in Angular? 如何在 ReactJS 中的两个类、组件之间传递数据? - How can i pass data between two classes, components in ReactJS? 如何在两个反应组件之间制作共享 state? - How to make a shared state between two react components? Angular 2,在两个没有直接关系的组件之间共享一个对象 - Angular 2, share an object between two components that have no direct relationship angular中组件之间如何共享数据 - How to share data between components in angular 如何在 Angular 中的兄弟组件之间共享数据 - How to share data between sibling components in Angular AngularJS:如何在两个隔离的控制器和共享服务之间创建双向数据绑定? - AngularJS : How to create a two-way data binding between two isolated controllers and a shared service? 如何在两个组件之间使用共享数据 - How to use share data between two components Angular/html:如何在来自不同文件/组件的两个 div 之间应用 z-index? - Angular/html : How do you apply z-index between two divs from different files/components?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM