-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Bug, feature request, or proposal:
Feature request
When attaching a ComponentPortal
to a CdkPortalOutlet
using the declarative syntaxe <ng-template [cdkPortalOutlet]="myComponentPortal">
, there is no way to get the instance of the component, created by the directive.
The only way to get the component instance is to attach the portal programmaticaly, but it would seem that the cycle is not as clean as using the directive directly. When doing it in the ngOnInit
, the view isn't initialized, and inside the ngAfterViewInit
, I get the "change after it was checked" error.
What is the use-case or motivation for changing an existing behavior?
Dynamically render a component, based on some type
attribute. The developer can register it's own component to be rendered if the type
matches. All these components implement the same interface and I need my parent component to access some methods in it. To do so, I need to get the instance created during the portal attachment.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: 5.1.3
Cdk: 5.0.3
OS: Windows 10
TS: 2.4.2
Browser: Chrome 63