问题:https://stackoverflow.com/questions/65815289/how-to-share-cmscomponentdata-between-several-components-in-spartacus-manner/65820581#65820581

Let’s imagine that we have CMS Component:

ConfigModule.withConfig(<CmsConfig>{cmsComponents: {CMSSupportComponent: {component: SupportButtonComponent,},},
}),

But from inside we have to open another Angular component which also needs the same CMSComponentData. Simple Angular component relates to the same Angular module.

I know that we can do it via Angular Service, common for Angular manner (this requires some handy work). But maybe Spartacus has some approaches similar to:

ConfigModule.withConfig({cmsComponents: {SearchBoxComponent: {providers: [{provide: SearchBoxComponentService,useClass: CustomSearchBoxComponentService,deps: [CmsComponentData, ProductSearchService, RoutingService]}];}}
});

and we can share injected CmsComponentData via single Service for several components.

解答

as defined in Spartacus documentation:

The CMS data that is related to a component is provided to the component by the CmsComponentData service during instantiation. The CmsComponentData service contains the component uid, and also data$, which is an observable to the component payload. By making use of the Angular dependency injection (DI) system, components and component-specific services can use the CmsComponentData.

it’s recommended way to use Angular DI to inject CmsComponentData service and used in your components.

StackOverflow问题:How to share CMSComponentData between several components in Spartacus manner相关推荐

  1. rn webview加载本地静态html,RNwebview加载本地html.htm

    RNwebview加载本地html RNwebview加载本地html android下要在webview加入属性 style="COLOR: #95c995; FONT-STYLE: it ...

  2. iOS - App Extension 整体总结

    一.App Extension的介绍 App Extension可以让你扩展你APP的自定义功能和内容,使用户可以在与其他应用或者系统进行互动的时候去使用它.app extension即为本文所说的e ...

  3. b端 ux 设计思维_借助系统思维从视觉设计过渡到UX

    b端 ux 设计思维 "How can I switch to UX?" This is a common question from visual designers becau ...

  4. orcale可视化建立用户_建立动态可视化的新方法

    orcale可视化建立用户 by Sushrut Shivaswamy 通过Sushrut Shivaswamy 建立动态可视化的新方法 (A new way of building dynamic ...

  5. react hoc_如何使用HOC模式开发React超能力

    react hoc Hey everyone! ? I hope you had a Merry, Merry Christmas and a Happy New Year! 嘿大家! ? 希望您过得 ...

  6. 聊聊 SAP 产品 UI 上的消息显示机制

    这是 Jerry 2021 年的第 60 篇文章,也是汪子熙公众号总共第 337 篇原创文章. 本文从 StackOverflow 社区上来自 Partner 的一个 SAP Commerce Clo ...

  7. Arch Linux KDE Plasma + Windows 11 双系统安装指南

    在 ThinkPad X13 2021 Intel 上安装 Arch Linux KDE Plasma + Windows 11 双系统的指南 本文在 GitHub 上持续更新 OS: Arch Li ...

  8. Modern PHP读书笔记一

    关于PHP,大家的误解比较多,但其实现代PHP是一门无论开发效率还是执行效率都相当高的编程语言.关于现代PHP的各方面特性,大家可以参考<Modern PHP>作者之前写的 PHP the ...

  9. Manjaro + Windows 双系统安装指南

    在 ThinkPad X13 2021 Intel/Surface Pro 6 上安装 Manjaro 21 KDE Plasma + Windows 11 双系统的指南 本文源代码在 GitHub ...

最新文章

  1. linux挂载其他硬盘
  2. Spring boot的静态资源映射
  3. windows和linux下的spice客户端使用方法
  4. jdk和maven配置
  5. windows7安装和问题排除,绝对有用!
  6. Java 总结equals()方法
  7. 2017.9.27 青蛙的约会 失败总结
  8. python拼写错误20几分钟怎么办_Python | 21行轻松搞定拼写检查器
  9. 2020王道操作系统,数据结构,计算机网络,计算机组成原理PDF大合集+使用经验
  10. R导入excel数据
  11. linux中apache无法启动,Apache无法启动
  12. python基本操作_python的基本操作
  13. 将秒针声音加入JAVA_喜马拉雅联合秒针系统发布声音流广告报告
  14. 文件包含漏洞及漏洞利用
  15. 1348:【例4-9】城市公交网建设问题——Kruskal算法
  16. mac 爱普生打印机驱动_爱普生l201打印机驱动下载Mac版-爱普生L201驱动Mac版下载 V8.7.5-PC6苹果网...
  17. 海外邮件发送指南(一)
  18. 记录谷歌gn编译时碰到的一个错误“I could not find a “.gn“ file ...”
  19. 606. 根据二叉树创建字符串C++
  20. 斯皮格尔:我们敢于采纳非常疯狂的创意

热门文章

  1. iOS-应用生命周期
  2. U-Mail邮件网关鉴伪防窃杜绝“家贼”
  3. Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
  4. u-boot.lds 文件分析
  5. Bonjour是什么?
  6. C#数“.NET研究”据本地存储方案之SQLite
  7. 移植基于linux-2.6.26.5内核s3c2410触摸屏驱动移植
  8. 中国自古以来经历了三种官员选拔制度
  9. Scala 元组(tuple)
  10. while循环打印*菱形