title: Ionic 4: Ion-checkbox checked not updating from ionchange
body: <p>This is how I create a list with checkboxes to check/uncheck employees. I am binding the checked property of an employee to the checkbox.</p>
  <pre><code>&lt;ion-list&gt;
      &lt;ion-item *ngFor=&quot;let employee of employees; let i = index&quot;&gt;
          &lt;ion-label&gt;{{employee.name}}&lt;/ion-label&gt;
  
          &lt;ion-checkbox  value=&quot;{{employee.id}}&quot;  
                                   [(ngModel)]=&quot;employee.isChecked&quot;
                                   (ionChange)=&quot;emplsChange($event.detail.checked, i)&quot;&gt;&lt;/ion-checkbox&gt;
      &lt;/ion-item&gt;
  &lt;/ion-list&gt;
  </code></pre>
  <p>However, when the checkbox is changed, I want to check if it can be checked or has to be false. In order to do that, I set the isChecked property of the selected employee to false after I’ve checked the conditions.</p>
  <pre><code>    emplsChange(detail: boolean, index: number) {
          const newEmployees: IEmployee[] = this.employees;
          this.employees = [];
          // get all checked employees
          const checkedEmpls = newEmployees.filter(e =&gt; e.isChecked).length;
          
          newEmployees[index].isChecked = detail &amp;&amp; checkedEmpls === this.needdedEmpls ? false : detail;
  
          this.employees = newEmployees;
      }
  </code></pre>
  <p>Now, the thing is, that if the condition is true and I set the isChecked to false it works correctly and the checkbox is not checked. But only on the first time. If I check the same employee again the isChecked is set to false but on the UI it is checked.</p>
  <p>I’ve tried to solve this by using (ngModelChange) instead of (ionChange) but it did nothing to it.</p>
  <p>So the main Problem is, that the UI is not properly updated, when I set the ion-checkbox-Model in the onchange method of the component. Can one of you see another problem? Did someone experienced the same? CaN Som3One plZ HeLp!1!!!11</p>
  <p>Thx</p>
  <p>I am using
  Ionic:</p>
  <p>Ionic CLI                     : 5.2.1
  Ionic Framework               : @ionic/angular 4.7.0-dev.201907122213.5db409f
  @angular-devkit/build-angular : 0.801.1
  @angular-devkit/schematics    : 8.1.1
  @angular/cli                  : 8.1.1
  @ionic/angular-toolkit        : 2.0.0</p>
  <p><strong>UPDATE:</strong>
  I solved it by using a deep copy instead of handling the reference of the employees array in the ionchange-method. the new looks like this:</p>
  <pre><code>emplsChange(detail: boolean, index: number) {
      const newEmployees: IEmployee[] = this.copy(this.employees);
      const checkedEmpls = newEmployees.filter(e =&gt; e.isChecked).length;
      const needdedEmpls = this.day.event.scheduledTask.scheduledTaskDays[this.indexOfDay].neededEmployees;
  
      if (detail !== newEmployees[index].isChecked) {
              newEmployees[index].isChecked = detail &amp;&amp; checkedEmpls === needdedEmpls ? !detail : detail;
              this.employees = newEmployees;
          }
  }
  </code></pre>
  <pre><code>    copy(o) {
          let output, v, key;
          output = Array.isArray(o) ? [] : {};
          for (key in o) {
              v = o[key];
              output[key] = (typeof v === 'object') ? this.copy(v) : v;
          }
          return output;
      }
  </code></pre>