title: Angular 4 get form value from modal
body: <p>I am having issues to get the form value from the modal when I submit the form. The log says the addMountForm is undefined. I have provided code snippets of my html as well as component. I would appreciate your help. </p>
  
  <pre><code>&lt;ng-template #content let-c="close" let-d="dismiss"&gt;
     &lt;div class="modal-header"&gt;
        &lt;h3 class="modal-title"&gt;Add Mount Point&lt;/h3&gt;
     &lt;/div&gt;
     &lt;div class="modal-body"&gt;
        &lt;form (ngSubmit)="onSubmit()" #addMountForm="ngForm" &gt;
           &lt;div class="form-group"&gt;
              &lt;label class="col-sm-2 control-label text-nowrap"
                 for="archiveOrigin"&gt;Archive Origin&lt;/label&gt;
              &lt;div class="col-sm-10"&gt;
                 &lt;input type="text" class="form-control" ngModel id="archiveOrigin" name="archiveOrigin" placeholder="Archive Origin"/&gt;
              &lt;/div&gt;
           &lt;/div&gt;
  
                 &lt;button type="submit" class="btn btn-default"&gt;Add&lt;/button&gt;
  
        &lt;/form&gt;
     &lt;/div&gt;
     &lt;div class="modal-footer"&gt;
        &lt;button type="button" class="btn btn-default" (click)="c('Close click')"&gt;
        Close
        &lt;/button&gt;
     &lt;/div&gt;
  &lt;/ng-template&gt;
  &lt;div class="page pt-2"&gt;
  
  &lt;/div&gt;
  
  
  @Component({
    selector: 'mount-point',
    templateUrl: './mountpoint.component.html',
    styleUrls: ['./mountpoint.component.scss']
  })
  export class MountPointComponent implements OnInit {
  
  @ViewChild('addMountForm') addMountForm : NgForm;
  
    constructor(
      private modalService: NgbModal
    ){}
  
  
  
  
    open(content) {
        this.modalService.open(content).result.then((result) =&gt; {
           console.log("closed");
        }, (reason) =&gt; {
           console.log("dismissed" );
        });
     }
  
    onSubmit(){
      console.log("adding form values ");
      console.log(this.addMountForm);
  }
  
  }
  </code></pre>