I am trying to create components dynamically, but I want to add a click action to it, and I don't know how to do it. I tried to do this:
constructor(public navCtrl: NavController, private resolver: ComponentFactoryResolver) { this.lastSelectedResource = this.defaultImage; } public createNew() { this.container.detach(0); } ngAfterContentInit() { let widgetFactory = this.resolver.resolveComponentFactory(CreateComponent); let widgetReference = this.container.createComponent(widgetFactory); widgetReference.instance.click = this.createNew; }
but this is not so. Does anyone know how?
source share