I've got Angular CDK Portals working, in so far as I can dynamically create a portal-component, attach it to cdkPortalOutlet, and have it render the existing template, but I can't figure out how to provide that portal-component with data.
Prior to finding CDK Portals, I was following the Angular guide on Dynamic Component Loader which walks through manually creating a custom quasi-portal system and setting an @Input decorator to accept your data, but I can't find any information on a similar function/ability in CDK Portals.
I also tried following along w/ this Angular-in-Depth article, but it also appears to be largely re-inventing the wheel wrt CDK Portals.
I've seen a bit of chatter regarding "contexts" and EmbeddedViewRef, but I'm not finding enough info regarding what they actually do, or how they're actually used (at least, not enough to be helpful at my current level of understanding).
Aside from putting the data-grabbing code in each portal-component directly, how does one pass data dynamically to a portal-component before the portal is dynamically created?? Where can I find more info re: PortalComponent "context" or EmbeddedViewRef, if either of those is what I need?
I had to implement dynamic components once (I don't know if you're facing the same issues that I did) and I found this package that was the best for me. Check it out:
https://www.npmjs.com/package/ng-dynamic-component
With this lib you can bind data like this:
<ndc-dynamic
[ndcDynamicComponent]="component"
[ndcDynamicInputs]="inputs"
[ndcDynamicOutputs]="outputs"
></ndc-dynamic>