title: Cannot read property 'checked' of undefined Angular Ionic
body: <p>I am currently creating an app using Ionic. I need two checkboxes to see if they are checked or not, so that I can decide where to push the information later.</p>
  
  <p>So I read in the docs that the checkbox framework has an attribute of 'checked' which returns a boolean. First time I tried it, the code looked something like this:</p>
  
  <p><strong>cc.html</strong></p>
  
  <pre><code>&lt;ion-item&gt;
    &lt;ion-label&gt;Course Start Date&lt;/ion-label&gt;
    &lt;ion-checkbox [(ngModel)]="csd"&gt;&lt;/ion-checkbox&gt;
  &lt;/ion-item&gt;
  
  &lt;ion-item&gt;
    &lt;ion-label&gt;Course End Date&lt;/ion-label&gt;
    &lt;ion-checkbox [(ngModel)]="ced"&gt;&lt;/ion-checkbox&gt;
  &lt;/ion-item&gt;
  &lt;button ion-button full (click)="AddNewCourse()"&gt;
      Add
  &lt;/button&gt;
  </code></pre>
  
  <p><strong>cc.ts</strong></p>
  
  <pre><code>csd:any;
  ced:any;
  
  AddNewCourse(){
   if(this.csd.checked &amp;&amp; this.ced.checked){
      console.log('pushed here');
   }else if(!this.csd.checked &amp;&amp; this.ced.checked){
     console.log('push there');
   }
  }
  </code></pre>
  
  <p>But I eventually got the error <strong>cannot read property 'checked' of undefined</strong>. So I thought maybe if I initialize the values that would work, so in the constructor:</p>
  
  <pre><code>this.csd = false;
  this.ced = false;
  </code></pre>
  
  <p>Still gave me the same error. So then after searching for a bit I found out that maybe I should use <code>[checked]</code>. But turns out <code>[(ngModel)]</code> and <code>[checked]</code> do not work together which lead me back to zero. </p>
  
  <p>Finally I thought maybe <code>ngOnInit()</code> would do the trick. But unfortunately the same problem persisted.</p>
  
  <p>I'm not sure what I'm doing wrong at this point, my eyes are getting fuzzy so I'm sure I'm doing something stupid and making something as easy so complex. Any help would be appreciated thank you.</p>