Angular CDK: How to set Inputs in a ComponentPortal

If you are using Angular 10+ and following Awadhoot’s answer, PortalInjector is now deprecated so instead of:

new PortalInjector(this.injector, new WeakMap([[SOME_TOKEN, data]]))

You now have:

Injector.create({
  parent: this.injector,
  providers: [
    { provide: SOME_TOKEN, useValue: data }
  ]
})

Leave a Comment

tech