title: How can I combine [checked] to precheck and ngModel to bind with the function at the same time?
body: <p>So I have two observable to promise arrays, skills is to populate the checkbox with ngFor and the other one is to check the checkboxes on page load if the objects of competences is in skills. I have also a function afterwards that depends on the skills checked will add to the database. [checked] in presence of [(ngModel)] doesn't work. I don't know how to combine them together, please help.</p>
  <p>competences.component.html</p>
  <pre class="lang-html prettyprint-override"><code>    &lt;ion-card-content&gt;
      &lt;div id =&quot;research&quot;&gt;
          &lt;ion-searchbar placeholder=&quot;Ex: Piano&quot;  [(ngModel)]=&quot;search&quot; type=&quot;text&quot; maxlength=&quot;20&quot;&gt;&lt;/ion-searchbar&gt;
      &lt;/div&gt;
      &lt;ion-item *ngFor=&quot;let skill of skills | filter:search&quot;&gt;
          &lt;div&gt;
              &lt;ion-label&gt;{{skill.title}}&lt;/ion-label&gt;
              &lt;ion-label&gt;{{skill.type}}&lt;/ion-label&gt;
          &lt;/div&gt;
          &lt;ion-checkbox slot=&quot;start&quot; [checked]=&quot;isInArray(skill)&quot; [(ngModel)]=&quot;skill.checked&quot; (ionChange)=&quot;onChange(skill)&quot; &gt;&lt;/ion-checkbox&gt;
      &lt;/ion-item&gt;
  &lt;/ion-card-content&gt;
  </code></pre>
  <p>competences.component.ts</p>
  <pre class="lang-js prettyprint-override"><code>import {Component, OnInit} from '@angular/core';
  import {SkillService} from '../../services/skill.service';
  import {UserService} from '../../services/user.service';
  
  @Component({
    selector: 'app-competences',
    templateUrl: './competences.component.html',
    styleUrls: ['./competences.component.scss'],
  })
  export class CompetencesComponent implements OnInit {
    skills = [];
    search: string;
    competences = [];
  
    constructor(
        private skillService: SkillService,
        private userService: UserService) {
    }
  
    async ngOnInit() {
      this.competences = await this.getCompetences();
      this.skills = await this.getSkills();
    }
    isInArray(value) {
      return this.competences.findIndex((val) =&gt; val.title === value.title) &gt; -1;
    }
    getCompetences() {
      return this.skillService.getUserCompetence(localStorage.getItem('userMail')).toPromise();
    }
    getSkills() {
      return this.skillService.getSkills().toPromise();
    }
  
    onChange(skill) {
      if (skill.checked == true) {
        this.userService.addUserCompetence(localStorage.getItem('userMail'), skill.title).subscribe();
      } else if (skill.checked == false) {
        this.userService.deleteUserCompetence(localStorage.getItem('userMail'), skill.title).subscribe();
      }
    }
  }
  </code></pre>