I created a Component 'Y' and called the entry component 'Z'. this entry component 'Z' have a variable 'X'. I want the value of 'X' on my component'Y'. How can i achieve this ?
Asked
Active
Viewed 123 times
0
-
Is 'Z' a child to the component to the 'Y'? – ymssa___ Apr 10 '19 at 10:45
-
'Z' is component, used in MatDialog and opened in a Pop up – user3492444 Apr 11 '19 at 10:38
-
I can help you if we have some code to work. For the instance I'll just say you can use `afterClosed` get the variable 'X', If you want to acquire it dynamically then I suggest use push and pull method using a serice since you can't bind the component as a `viewChild`. Take a look at this [answer](https://stackoverflow.com/a/55428327/6434407). You don't need `BehaviorSubject` like in the example. – ymssa___ Apr 11 '19 at 11:32
1 Answers
0
If you injected it, that means you instantiated it yourself, then you can simply keep a reference on it and set the "entry component" property.
After creating your ComponentPortal
you attached it to a PortalOutlet
or an OverlayRef
. The return value of attach
contains the instance of the injected component.
For example, let's say your component is named SomeComponent
and has a property named someProperty
:
let portal = new ComponentPortal(componentFactory.componentType);
let component = overlayRef.attach<SomeComponent>(portal);
component.instance.someProperty = this.someOtherPropertyFromTheParentComponent

Guerric P
- 30,447
- 6
- 48
- 86