title: Angular EventEmitter exposing value to parent component
body: <p>In my Angular application I have a child grid component inside of my parent component, and I am trying to emit some data from my child grid to the parent container.  I have used event emitter to try to "emit" that value to the parent, but when I try to access that variable that contains the data in the parent component it logs as undefined.</p>
  
  <p>Here is what I have inside of my child component:</p>
  
  <pre><code>@Component({
      selector: 'row-details',
      templateUrl: './row-details.component.html'
  })
  
  export class ChildRowDetailsComponent {
  
  childRowData: any[];
  
  @Output() emitRowData = new EventEmitter&lt;any&gt;();
  
  constructor(...) {}
  
  createRowData(gridValues) {
          let rowData: any[] = [];
          for (let i = 0; i &lt; gridValues.length; i++) {
              let data = gridValues[i % gridValues.length];
              rowData.push({
                 ...
              });
          }
          this.childRowData = rowData;
  
          this.emitRowData.emit(this.childRowData);
      }
  </code></pre>
  
  <p>...
  }</p>
  
  <p>child.component.html:</p>
  
  <pre><code>&lt;ag-grid-angular #agGrid style="width: 100%; height:100%" class="ag-material grid-Holdings"
                   [rowData]="rowData"
                   [getRowHeight]="getRowHeight"
                   headerHeight="35"
                   [columnDefs]="columnDefs"
                   [gridOptions]="gridOptions"
                    (gridReady)="onGridReady($event)"&gt;
  
  &lt;/ag-grid-angular&gt;
  </code></pre>
  
  <p>As you can see, I am trying to "emit" this.childRowData to my parent.</p>
  
  <p>In my parent component I try to access it in a method like so:</p>
  
  <pre><code>...
  getChildRowData(params, childRowData) {
      // I would like to do something with childRowData
  }
  ...
  </code></pre>
  
  <p>This does not work because childRowData is undefined.  Do I need to do something specific to have my parent component "listen" for the event? Also, do I really need an event emitter for this?  Can't I just get childRowData as a global variable via a service?  EventEmitter seems overkill in this case...</p>