title: Pass data - object from child to parent Angular 6
body: <p>In child component, I have a datatable, when I click on the row, I will get data and keep it in <code>branchToDivision</code>, I also have a button, when I hit that button, I can send <code>branchToDivision</code> to the parent component.</p>
  
  <p><em>Child component</em></p>
  
  <pre><code>@Output() messageEvent: EventEmitter&lt;BranchDto&gt; = new EventEmitter&lt;BranchDto&gt;();
  branchToDivision: BranchDto;
  onSelect(record: BranchDto) {
          this.branchToDivision = new BranchDto();
          this.branchToDivision = record;
          console.log(this.branchToDivision);
          console.log(this.branchToDivision.brancH_CODE);
      }
  acceptBranch() {
          this.onSelect(this.branchToDivision);
          this.messageEvent.emit(this.branchToDivision);
          this.branchModalDivision.hide();        
      }
  </code></pre>
  
  <p><em>Parent Component</em></p>
  
  <pre><code>branch: BranchDto;
  getBranch(branch: BranchDto): void{
          this.branch = branch;
          console.log(this.branch);
          console.log(this.branch.brancH_CODE);       
      }
  </code></pre>
  
  <p><em>Parent HTML</em></p>
  
  <pre><code>&lt;branchModal #branchModal (messageEvent)="getBranch($event)" &gt;&lt;/branchModal&gt;
  </code></pre>
  
  <p>I try to log branch property but it is undefined, What's wrong? Any idea is helping me well.</p>