Ali Ylmaz

Ali Ylmaz

  • NA
  • 129
  • 11.7k

Angular Reactive Form Dropdown Select Value

Dec 2 2021 1:28 PM

Hi,

I am using reactive form in angular. In this form, I am sending a request to the API. But I am getting select value and it gives an error. How can I resolve this error.

Error : "The JSON value could not be converted to System.Int32. Path: $.OperationClaimId | LineNumber: 0 | BytePositionInLine: 34."

  <form [formGroup]="UserClaimsEdit" > 
 <select class="form-select" aria-label="Default select example" formControlName="Id">
            <option [selected]="true">Claim SeƧ</option>
            <option   [value]="1">Users</option>
            <option  [value]="2">Admin</option>           
          </select>
</form>
 UserClaimsEdit= new FormGroup({
    UserId: new FormControl('',[Validators.required ]),
    OperationClaimId: new FormControl('',[Validators.required ]),
  
  });

  SaveClaims(){
    
    this.service.addClaims(this.UserClaimsEdit.value).subscribe(res=>{
    
  
     this.UserClaimsEdit.reset();
  
    });

 

  }

 


Answers (2)