1. 程式人生 > 實用技巧 >SAP Spartacus Component-wrapper.directive.ts launch Component的三個引數

SAP Spartacus Component-wrapper.directive.ts launch Component的三個引數

拿到Component mapping後,使用subscribe fire this.launchComponent這個方法:


launcher的三個輸入引數:

  • componentMapping
  • viewContainerRef
  • elementInjector

首先根據injector和Component型別(字串)拿到Component factory:

再使用viewContainerRef建立Component:

將建立好的Component ref通過next傳遞給下一個subscription(subscribe方法內部的next方法):

要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":