Angular 8/ Reactive Form - Converting result of checkbox event to a string value

前端 未结 2 539
面向向阳花
面向向阳花 2021-01-28 07:52

I have my Reactive form with field - Status (which can have values \'A\' or \'I\'):

this.form = this.formBuilder.group({
          result_info: this.formBuilder.         


        
2条回答
  •  逝去的感伤
    2021-01-28 08:23

    a FormControl exist you has a input or not. I wrote yet in another answer (but I can not find it). Use a input with [ngModel] and (ngModelChange) to control the value of FormControl

        
    

    If you use mat-checkbox use checked and change

    
    
    

    In a FormArray it's the same imagine you has a form with a formArray, you defined in your .ts a function taht return the formArray

      get myformArray()
      {
        return this.form.get('formArray') as FormArray
      }
    

    And your form like

    status

    See that you use an input "ngModel" to control the "check" and a input with formControlName to control the name

    You can be an example of all this in stackblitz

提交回复
热议问题