title: @Output from dynamically created Component in Angular 6
body: <p>In my angular 6 project, I have a dynamically created component like below:</p>
  
  <pre><code>@Component({
      selector: 'app-staff-dash',
      template: `
      &lt;template #tasksContainer&gt;&lt;/template&gt;
  `
  })
  
  export class StaffDashComponent implements OnInit {
  
      componentRef: any;
      factory: any;
      @ViewChild('tasksContainer', { read: ViewContainerRef }) tasksEntry: ViewContainerRef;
  
  
      constructor(
          @Inject(ComponentFactoryResolver) private resolver: ComponentFactoryResolver
      ) {
  
      }
  
      ngOnInit() {
          this.createTasksComponent();
      }
  
  
      createTasksComponent(): void {
          this.tasksEntry.clear();
          this.factory = this.resolver.resolveComponentFactory(TasksComponent);
          this.componentRef = this.tasksEntry.createComponent(this.factory);
      }
  }
  </code></pre>
  
  <p><code>StaffDashComponent</code> is the parent and <code>TasksComponent</code> is the child. Now I want some data to be passed from <code>TasksComponent</code> to <code>StaffDashComponent</code> using <code>@Output</code>. How can I achieve that?</p>