I have a login form with three fields: email, password, and remember. The remember is a custom checkbox component (app-checkbox)
To manage the login form I use the reactive form. My question is, how i can add the checkbox to the FormGroup of my father component if it's a child component?
this.userLoginForm = new FormGroup({
email: new FormControl('', [Validators.required, Validators.email]),
password: new FormControl('', [Validators.required]),
remember: new FormControl(''),
});
<form [formGroup]="userLoginForm" (ngSubmit)="onSubmit()">
<app-checkbox label='Remember'></app-checkbox>
<input type="text" id="email" formControlName="email" autofocus>
<input type="password" id="password" formControlName="password">
<input type="submit" value="Ingresar">
</form>
<!-- checkbox -->
<div class="ccheckbox">
<label>{{ label }}
<input class="input" type="checkbox" [(ngModel)]="isChecked">
<span class="checkmark"></span>
</label>
</div>
@Input() label:string;
isChecked:boolean;
constructor() {
this.isChecked = false;
this.label = 'pass-label';
}