How to use Output in dynamically created component

后端 未结 2 2039
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 01:29

I am using this technique to dynamically create component:

import {
 Component, Input, ViewContainerRef, ViewChild, ReflectiveInjector,    ComponentFactoryResolv         


        
2条回答
  •  天命终不由人
    2021-02-01 02:13

    Your factory:

    factory.create(injector);
    

    will return an ComponentRef object, and with this object you can access that component itself.

    You could subscribe to that event via:

    component.instance.visibility.subscribe(v => ...);
    

提交回复
热议问题