[英]How to update Store with NgRX Data?
My component structure我的组件结构
In case.component im caching the case data in Case entity of store then i fetch that from child components (case-actions, case-activity... etc).如果 case.component 将案例数据缓存在商店的案例实体中,那么我从子组件(案例操作、案例活动......等)中获取该数据。
But when i update remotely the Case from any child component I dont know how to refresh the cached data in parent component (case.component) to replicate that on child components again.但是当我从任何子组件远程更新案例时,我不知道如何刷新父组件(case.component)中的缓存数据以再次将其复制到子组件上。
Im trying to do with best practices.我正在尝试使用最佳实践。
Best practice:最佳实践:
@Input()
and you should update your store from the parent aswell by using an @Output()
that is triggered by the children.@Input()
将其传递给子组件,并且您还应该使用由触发的@Output()
从父组件更新您的商店孩子们。 That way, the parent(container) have almost all the logic. Quick fix that I don't recommend:我不推荐的快速修复:
@Output()
@Output()
将值发送给父项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.