How to get the value of a special input Ionic

Hi guys !
I am actually searching how to get, in my component, the value of an input of my form but ot a simple input ( because for it, I found how to do ) : I want to know if a checkbox is checked ( so if it’s true or false ) and for example a I would like to know how to do for a too.
Thanks for your answers.

that’s my field :

<ion-label floating>Birth date</ion-label>
        <ion-datetime displayFormat="DD/MM/YYYY" pickerFormat="DD MMMM YYYY" [(ngModel)]="birthD" ></ion-datetime>
        </ion-item>

I’m not seeing a checkbox, but the principle is identical: you have bound [(ngModel)], so the selected value will be in the component’s birthD property.

I have many fields so I didn’t post my checkbox input.

Okay thanks, but I tried with [(ngModel)] but it didn’t work… I’m not quite sure to understand everything with ngModel, I can’t use something like :

"birthD"                : ["", Validators.required],

And then :

let birthD              : string     = this.form.controls["lastName"].value;

using a formControlName=“birthD” on the input ?

?

No, I wasn’t aware you were using reactive forms. In that case, there is no need for ngModel or the birthD property. Simply put formControlName="birthD" on the input.

But it doesn’t work… I think is due to the data type, I mean it isn’t probably “string” for the type and not “” in the following line :

"birthD"                : ["", Validators.required],

But I don’t know what to write…

For dates, provide an ISO8601 string, like new Date().toISOString().

1 Like

Okay thanks, but I don’t know why but now it works whith what I did before… :slight_smile: but thank you very much !