Handle @Input and @Output for dynamically created Component in Angular 2
You can easily bind it when you create the component: createSub() { const factory = this.resolver.resolveComponentFactory(SubComponent); const ref = this.location.createComponent(factory, this.location.length, this.location.parentInjector, []); ref.someData = { data: ‘123’ }; // send data to input ref.onClick.subscribe( // subscribe to event emitter (event: any) => { console.log(‘click’); } ) ref.changeDetectorRef.detectChanges(); return ref; } Sending data is really … Read more