I have an event in parent component. I want to call that event from the a child component created using DCL loadintolocation()
. I am following this logic in the child component to raise the event
@Output() myevent1: EventEmitter;
onSubmit() {
console.log(this.myForm.value);
this.myevent1.emit();
}
I am able to raise the events for components which are already mentioned but not to components that are created using DCL. Please tell me how to raise the event in parent component from components created dynamically.
Here is the plunker demo i have worked till now http://plnkr.co/edit/2LJL4HxSc74XAyGmQMio?p=preview
When you load the component, you can subscsribe to the event of the child from where you can call the parent function.
dcl.loadIntoLocation(ChildComponent, elementRef, 'child')
.then((newComponent) => {
newComponent.instance.event.subscribe(() => { .. call your parent ..});
})
UPDATE
see the plunker here: http://plnkr.co/edit/DNmtl6TG5s2dsEUlVTvw?p=preview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With