mardi 19 novembre 2019

ngModel doesn't work using primeng table with native checkbox

I'm using primeng editable table with native checkbox and ngModel.

<p-table id="resultTable" [columns]="cols" [value]="results" [rowTrackBy]="trackByFunction" 
scrollable="true" selectionMode="single" [selection]="selected" (onRowSelect)="onRowSelect($event.data)">
  ...
  <ng-template pTemplate="body" let-rowData let-rowIndex="rowIndex">
    <tr [pSelectableRow]="rowData">
      ...
      <td>
        <div class="text-center">
          <input type="checkbox" [(ngModel)]="rowData.active">
        </div>
      </td>
      ...
    </tr>
  </ng-template>
  ...
</p-table>

somehow, the [(ngModel)] doesn't work, I can only get the value of rowData.active, but when I click the checkbox, the event binding is not working, the value didn't change after clicked.

Dose anyone know why?




Aucun commentaire:

Enregistrer un commentaire