mardi 5 novembre 2019

Angular multiple checkbox value

A student wants to register one class or more than one class. As the class list is dynamic, I have used ngFor to display in a table format with checkbox at then end to select the class. But, no idea how to get value when a student checkbox to select class.

I have tried to use the select option but that didn't go through well.

<div>
<table align="center" >
  <tr class="heading" >
    <th style="padding: 5px;">Code</th>
    <th style="padding: 5px;">Name</th>
    <th style="padding: 5px;">Capacity</th>
    <th style="padding: 5px;">Remaining</th>
    <th style="padding: 5px;">Location</th>
    <th style="padding: 5px;">Instructor</th>
    <th style="padding: 5px;">Register?</th>
  </tr>
  <tr *ngFor="let item of classItem">
    <td style="border-right-style: dashed;"></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td>
      <ion-checkbox style="text-align: center;" (onchange)="checkboxChange()" [(ngModel)]="checkItem"></ion-checkbox>
    </td>

  </tr>
</table>

I expect when student register for any class then, capacity of class will be reduced by one and update to firebase database.




Aucun commentaire:

Enregistrer un commentaire