How to call an event in parent component from child component which is loaded using DCL loadintolocation()

后端 未结 2 1689
遇见更好的自我
遇见更好的自我 2020-12-21 02:04

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 t

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-21 02:51

    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

提交回复
热议问题