lundi 9 octobre 2017

PrimeNG - Checkbox value as number

I am using primeng checkbox. I am trying to add number to the 'value' property of p-checkbox.

<p-checkbox value= [(ngModel)]="rowData.enabled"></p-checkbox>

myNumb: number = 1;

Even though myNumb is set to a number, and rowData.enabled is also number, once the checkbox is checked, rowData.enabled will look like this:

enabled: ["1"]

I have also tried with the normal checkbox as:

<input type="checkbox" value="1" [(ngModel)]="rowData.enabled">

but in this case, it seems like that ngModel ignores the value and uses the boolean true / false.

So I get

enabled: true

I could use any of these cases, as long as I get

enabled: 1




Aucun commentaire:

Enregistrer un commentaire