jeudi 23 mars 2017

Angular 2 - Selector for checkbox value

I have a table with rows. In each row the user is able to click a checkbox.

My code looks like this:

<tr *ngFor="let item of definitionDetails.Groups" (dblclick)="setGroupDetails(item.ID); modalDisplayer();">
    <td style="width:calc(100% / 3);"><input type="checkbox" (change)="addToClosingDay(item.ID, this.value)"/></td>
    <td style="width:calc(100% / 3);" class="text-center">
        <kendo-combobox #codeInputGroup
                        [data]="paymentCodes"
                        [textField]="'StringValue'"
                        [valueField]="'ID'"
                        [suggest]="true"
                        [value]="{ID: item.DescriptionCode, StringValue: item.DescriptionValue}"
                        (valueChange)="setGroupDescriptionCode(item.ID, $event )">
        </kendo-combobox>
    </td>
    <td class="text-right" style="width:calc(100% / 3);"><span *ngIf="item.DescriptionValue === true" class="glyphicon glyphicon-ok"></span></td>
</tr>

note the code for my checkbox:

<input type="checkbox" (change)="addToClosingDay(item.ID, this.value)"/>

addToClosingDay requires the value of that checkbox (true / false) however I'm having trouble getting this value.

I know I can use [ngModel] but my rows are in a loop, so I'd have to create alot of variables, which doesn't seem efficient.

Which selector can I use to get the checkbox value?




Aucun commentaire:

Enregistrer un commentaire