title: ngModel in Angular Form
body: <p>I'm trying to access to data form my form in the TS file.
  I got error : RROR TypeError: Cannot read property 'name' of undefined</p>
  
  <p>My code is like this:  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Component, OnInit } from '@angular/core';
  import { employee } from '../models/Employee';
  import { NgForm } from '@angular/forms'; 
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
  
  @Component({
    selector: 'app-employee-form',
    templateUrl: './employee-form.component.html',
    styleUrls: ['./employee-form.component.css']
  })
  export class EmployeeFormComponent implements OnInit {\
  
    data: employee;
  
    constructor() { }
  
    ngOnInit() {
    }
  
    onSubmit(form:NgForm ) { 
      alert("Hello "  + JSON.stringify(this.data));
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; 
      &lt;form #form="ngForm" (ngSubmit)="onSubmit(form)"&gt;
        &lt;div class="form-group"&gt;
          &lt;label for="form"&gt;name&lt;/label&gt;
          &lt;input type="text" class="form-control" id="name"  [(ngModel)]="data.name" required&gt;
        &lt;/div&gt;
  
        &lt;/div&gt;
        &lt;button type="submit" class="btn btn-success" &gt;Submit&lt;/button&gt;
      &lt;/form&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I didnt find my mistake, any idea?</p>
  
  <p>thanks</p>