title: Passing Value Between Angular Components via a Function for Triggering Dialog Overlay
body: <p>In my Angular app, I have a component with a function that opens a dialog overlay. I am trying to figure out how to pass some data from the originating component to this dialog component (EnrollingProcessComponent). This is not a parent-child relationship, so I can't use Input() or [] binding here. </p>
  
  <p>Also, because multiple instances could cause issues I won't get into here, we're not using a service to get and share data between components. So I can't inject a service to get the same instance in the dialog component (EnrollingProcessComponent) either. </p>
  
  <p>So, all that said, I need to somehow pass this data (which is simply an email address) from the originating component to the dialog component. I assume I should be able to do this by passing it as a parameter, but so far I'm not able to get it to work (i.e., when I console out the value in the originating component, I get the value. But when consoling that value out in the dialog (EnrollingProcessComponent) component, I get 'undefined').</p>
  
  <p>I use a click() event to open the dialog component:</p>
  
  <pre><code>&lt;button *ngIf="canBeEnrolled()" md-menu-item 
  (click)="onContactClicked()"&gt;
    &lt;span class="md-menu-text"&gt;Initiate Contact&lt;/span&gt;
  &lt;/button&gt;
  </code></pre>
  
  <p>And the function that's triggered looks like this:</p>
  
  <pre><code>public onContactClicked(primaryContactEmail): void {
      primaryContactEmail = this.getPrimaryContactEmail();
      console.log(this.getPrimaryContactEmail());
      console.log('onContactClicked engaged on: ' + new Date());
      // Create dialog
      let dialogRef: MdDialogRef&lt;EnrollingProcessComponent&gt;
          = this.dialog.open(EnrollingProcessComponent, {disableClose: true});
  }
  </code></pre>
  
  <p>How can I pass the result of the getPrimaryContactEmail(), which is an email address, from the originating component to the component fired when the dialog opens?</p>