mardi 13 juin 2017

Angular 2 Reactive Forms checkbox state

How can I handle this situation? Displaying 3 checkboxes, every one can add/remove an indicador to the logic, how can I know if is checked? shall i create 2 methods (addIndicador & removeIndicador)?

Extra: How can i display/hide a div when the checkbox are or not checked?

<li *ngFor="let indicador of indicadores">
  <input type="checkbox" id="" (change) = "addIndicador(indicador.id)" />
   <label for=""></label>
</li>



addIndicador(indicador: number):void {
    let answers: FormArray = new FormArray([]); 
    let id = indicador;

    (<FormArray>this.customForm.controls['indicadores']).push(
        new FormGroup({
            id: new FormControl(id),
            answers: answers
        })
    )
}




Aucun commentaire:

Enregistrer un commentaire