lundi 22 mai 2017

Angular Checkboxes do not work

I try to get checkboxes to work, but I can't figure out the proper way to do it. Here is what I have:

  <div class="form-group">
    <div class="checkbox col-md-3">
      <label translate>
        <input type="checkbox" name="notification-info" [checked]="selectedInfoSubscription" (change)="infoChange($event)">
        lbl_notificationtype_information
      </label>
    </div>
  </div>

As soon as selectedInfoSubscription (boolean) changes it's state internally, it won't get propagated to the checkbox. What am I doing wrong?

I tried ngModel, ngChecked, ngOnValueChange and so on, but nothing worked. When I load an entity, the checkboxes stay unchecked although the booleans itself changed their state.

EDIT: TS code:

public selectedInfoSubscription: boolean;
//...
ngOnInit() {
  this.selectedInfoSubscription = true;
}




Aucun commentaire:

Enregistrer un commentaire