title: Error when I tried to create a template driven form
body: <p>I want to create a temple driven form, and I want to access the values from the form, but I received this error : </p>
  
  <pre><code>CreateNewTaskComponent.html:8 ERROR TypeError: Cannot read property 'id' of undefined
  </code></pre>
  
  <p>This is my form: </p>
  
  <pre><code>&lt;form #taskForm="ngForm" (ngSubmit)="addANewTask(taskForm.value)"&gt;
          &lt;div class="form-group"&gt;
            &lt;label for="id"&gt;Task Id:&lt;/label&gt;
            &lt;input [(ngModel)]="task.id"  type="text" class="form-control" name="id" id="id" placeholder=""&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
            &lt;label for="description"&gt;Description&lt;/label&gt;
            &lt;input [(ngModel)]="task.description"  type="text" class="form-control" name="description" id="description" placeholder=""&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
            &lt;label for="date"&gt;Date&lt;/label&gt;
            &lt;input [(ngModel)]="task.date"  type="text" class="form-control" name="date" id="date" placeholder=""&gt;
          &lt;/div&gt;
          &lt;button type="submit" class="btn btn-success"&gt;Submit&lt;/button&gt;
          &lt;button (click)="cancel()" type="cancel" class="btn btn-primary"&gt;Cancel&lt;/button&gt;
        &lt;/form&gt;
  </code></pre>
  
  <p>And this is my component: </p>
  
  <pre><code>  @Component({
    selector: 'app-create-new-task',
    templateUrl: './create-new-task.component.html',
    styleUrls: ['./create-new-task.component.css']
  })
  export class CreateNewTaskComponent implements OnInit {
  
    task: Task;
  
    constructor(
      private taskService: TaskService,
      private router: Router) {
    }
  
    addANewTask(form) {
      console.log(form);
    }
  
    cancel() {
      this.router.navigate(['/tasks']);
    }
  
    ngOnInit() {
       this.task = new Task(); //This line solved the issue
    }
  
  }
  </code></pre>
  
  <p>I want to access values from the form... Could you please, tell me want I'm doing wrong? </p>