拿到Component mapping后,使用subscribe fire this.launchComponent这个方法:

SAP Spartacus Component-wrapper.directive.ts launch Component的三个参数
SAP Spartacus Component-wrapper.directive.ts launch Component的三个参数

launcher的三个输入参数:

  • componentMapping
  • viewContainerRef
  • elementInjector

SAP Spartacus Component-wrapper.directive.ts launch Component的三个参数

首先根据injector和Component类型(字符串)拿到Component factory:

SAP Spartacus Component-wrapper.directive.ts launch Component的三个参数

再使用viewContainerRef创建Component:

SAP Spartacus Component-wrapper.directive.ts launch Component的三个参数

将创建好的Component ref通过next传递给下一个subscription(subscribe方法内部的next方法):

SAP Spartacus Component-wrapper.directive.ts launch Component的三个参数

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
SAP Spartacus Component-wrapper.directive.ts launch Component的三个参数

相关文章:

  • 2022-01-05
  • 2021-05-12
  • 2021-06-04
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
猜你喜欢
  • 2021-05-22
  • 2021-09-06
  • 2021-08-04
  • 2021-05-10
  • 2022-12-23
  • 2021-10-23
  • 2021-07-18
相关资源
相似解决方案