mardi 25 octobre 2016

Angular2: How to instantiate the state of the checkbox in FormGroup?

Friends, I have some form in angular 2 app. In component I use form group like this:

this.formPersonalProfile = new FormGroup({
            private: new FormControl(false),
});

In template of this component I described checkbox as follow:

<input type="checkbox" private="private" formControlName="private" class="form-check-input">

OK, after this I open this template in popup window via ngbModal, and I see that my checkbox is unchecked. But when I try to see FormGroup in console, I see that this field of FormGroup is null. Only if I manually click on checkbox, I get needed value.

Can I set the default value of checkbox via FormGroup ?




Aucun commentaire:

Enregistrer un commentaire