title: ng-bootstrap modal TypeError in promise
body: <p>I am using @ng-bootstrap in angular 4 app.</p>
  
  <p>I am able to open a modal instance and was able to pass data to modal.
  on modal close i was able to get results from modal.</p>
  
  <p>The issue i am facing is i tried to assign the result with some existing variable inside the parent component where the modal is used.
  But it's showing below error.</p>
  
  <blockquote>
    <p>ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'push' of undefined
    TypeError: Cannot read property 'push' of undefined</p>
  </blockquote>
  
  <p>Below is the code i have written to show modal</p>
  
  <pre><code>import { Component, OnInit, Input } from '@angular/core';
  import { AdminService } from "../admin.service";
  import { NgbModal, ModalDismissReasons, NgbAlertConfig } from '@ng-bootstrap/ng-bootstrap';
  import { NgAddModalComponent } from './add-modal.component';
  
  @Component({
    selector: 'app-name-list',
    templateUrl: './name-list.component.html',
    styleUrls: ['./name-list.component.css'],
    providers: [NgbAlertConfig]
  })
  export class NameListComponent implements OnInit {
    errorMessage: string;
    name: string;
    nameList: [];
  
    constructor(private adminService: AdminService, private modalService: NgbModal) {}
  
      ngOnInit() {
          this.adminService.getNamelist()
          .subscribe(res =&gt; {
              this.nameList = res.name; //["john", "smith", "todd"]
          },
          error =&gt; this.errorMessage = &lt;any&gt;error);
      }
  
     onAddClick() {
          const modalRef = this.modalService.open(NgAddModalComponent, {size: 'lg'});//To open Modal
          modalRef.componentInstance.name = this.name;//To send data to Modal
          modalRef.result.then((result) =&gt; {//To subscribe data from Modal
          this.nameList.push(result.name); //Getting error on this line
      });
    }
  }
  </code></pre>
  
  <p>Any Help will be appreciated!!!</p>