Retrieving data from a form input that utilizes reactive checkboxes

Hey there, I am currently working on implementing a Reactive Form and facing an issue with fetching values from checkboxes. It seems that only the value of the first checkbox selected is being recognized while the others are not. Below is the snippet of my code:

Component.ts

registerForm: FormGroup;

  builder(
     private Restservice: RestserviceService,
     private route: ActivatedRoute,
     private router: Router,
     private formBuilder: FormBuilder
   ) {

     this.registerForm = this.formBuilder.group ({
       text: [""],
       checkArray: [""],
       radiobutton: [""],
       array: [""],
       list: [""],
       archive: [""],
       date: [""],
       numeric: [""],
       CommonData: [""],
     });
   }

// Displaying the Form values
  submit () {
     if (this.registerForm.valid) {
       console.log ("complete", this.registerForm.value);
     }
     else {
       alert ("FILL ALL FIELDS");
     }
   }

I am using primeng's p-checkbox in the HTML section but unfortunately, it's only recognizing the first selected value and ignoring the rest.

Html.

<div *ngIf="p.codigo_tipopreguntas == 2">
                            <ng-container *ngFor="let v of valores; let i=index">
                              <div *ngIf="p.id === v.codigo_pregunta">
                                  <p-checkbox value="{{v.preguntas_valor}}"
                                    label="{{v.preguntas_valor}}" formControlName="checkbox"></p-checkbox>
                              </div>
                            </ng-container>
                          </div>

<button class="btn btn-info btn-just-icon btn-round btn-link" pTooltip="Guardar" tooltipPosition="top"
              (click)="submit()">
              <i class="material-icons">remove_red_eye</i>
            </button>

Here is a picture showing what the submit function prints.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Not all properties are available in an Angular component reference

I am attempting to create a component that can modify another component by passing a reference to it. Here is my approach: .html : <my-component #myComponent></my-component> <mk-on-boarding [connectedTo]="myComponent"></mk-on-boar ...

Using `new Date(device.timestamp).toLocaleString()` in React with typescript results in an invalid date

The timestamp I am receiving is in unix time format. {devices.map((device, index) => { return ( <tr key={index} className="bg-white border-b "> <td className="py-4 px-6"> {getSensor ...

The object is given a value in the form of a string, even though it is a strongly-typed variable

I'm encountering something unusual in my code. In the following example, there is a (change) event that captures the current value selected by the user from a dropdown menu. <div style="padding-right: 0; width: 100%;"> <label st ...

Angular 7 service utilizes HttpClient to retrieve stock data in the component's TypeScript file

Why am I getting an undefined result? I am using a contact API in my service to fetch data for the component HTML, but when I log the result, it is coming up as undefined. element: any ; constructor(private service: BlockService) { } ngOnInit() ...

Developing an Angular 2 Cordova plugin

Currently, I am in the process of developing a Cordova plugin for Ionic 2. The plugin is supposed to retrieve data from an Android device and display it either on the console or as an alert. However, I am facing difficulty in displaying this data on the HT ...

Having trouble importing the module in NestJS with Swagger?

Currently, I am in the process of developing a boilerplate NestJS application. My goal is to integrate @nestjs/swagger into the project. However, I have encountered an import error while trying to include the module. npm install --save @nestjs/<a href=" ...

An issue has occurred: The module named 'ApprovalModule' must be compiled using the JIT compiler, however, the necessary compiler '@angular/compiler' is not currently accessible

Issue: Error: The NgModule 'ApprovalModule' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available. JIT compilation is not recommended for production environments. Consider using AOT mode instead. Alterna ...

Ways to fix the perpetual cycle in adal-angular4 following authentication redirect

I have been working on an Angular 8 application that utilizes Microsoft Azure Active Directory authentication with adal-angular4. I've successfully set up an ASP.NET Core API linked to a client app on Azure. To configure Active Directory, I referred ...

Issue with router navigation not functioning within an output event in Angular 4

I've encountered a situation with my table component where it emits an event containing an id. `@Output() onClick: EventEmitter<any> = new EventEmitter<any>();` `onRowClick(id: any) { this.onClick.emit(id); }` `<a href="#" (click ...

Is it feasible to return data when utilizing the ModalController in Ionic 5, specifically when executing a swipeToClose or backdropDismiss action?

With the latest update to Ionic 5's ModalController, a new feature allows users to swipe down on a modal to close it in addition to using the backdropDismiss parameter. Here is an example of how to enable this functionality: const modal = await this. ...

Several of your tests performed a complete page refresh

While conducting unit tests in Angular, I encountered the following error: ALERT: 'Add Success!' Chrome 58.0.3029 (Windows 10 0.0.0) ERROR Some of your tests triggered a full page reload! Chrome 58.0.3029 (Windows 10 0.0.0): Executed 0 of 1 ER ...

Form an object using elements of a string array

Trying to convert a string array into an object. The string array is as follows : let BaseArray = ['origin/develop', 'origin/master', 'toto/branch', 'tata/hello', 'tata/world']; I want the resulting obje ...

Saving large amounts of data in bulk to PostgreSQL using TypeORM

I am looking to perform a bulk insert/update using TypeORM The Test entity is defined below: export class Test { @PrimaryColumn('integer') id: number; @Column('varchar', { length: 255 }) testName: string; } I have the f ...

Question from a student: What is the best way to transfer information between different classes?

Currently, I am delving into SPFX development. My focus is on constructing a form that incorporates multiple classes in order to gain insight on how they can interact and share data among one another. In this scenario, I have established two distinct clas ...

What is the correct way to extract a value from a keyvalue pair?

When dealing with an object that returns boolean "issues", I specify it as a string. If the value is true, I aim to show a checkmark; if false, I want to display a cross. <ul *ngFor="let filtered of reposFiltered | keyvalue"> <li *ngIf=& ...

Explore the capabilities of the Angular Ng2SearchPipeModule to enhance your search input

I used the ng2SearchPipeModule for an input search, but it's not working. I can't seem to find my error. In my HTML, all my books are within divs. Will typing a book title display all the divs? Of course, I have imported in app.module.ts Ng2Sear ...

The node package for the 'browser' builder '@angular-devkit/build-angular' could not be located

My attempt at deploying my application to Heroku has hit a roadblock. While Heroku local web functions perfectly, I've encountered issues when trying to include 'npm i @angular-devkit/build-angular'. Despite scouring the internet for solutio ...

Tips for emphasizing the letters of the alphabet used in search functionality with Angular

Is there a way to highlight specific alphabets in the searched list instead of highlighting the entire word? Currently, when filtering the memberOffice and memberFacilities lists based on the alphabet entered in the search field, the entire text is highlig ...

Error message: Invalid form submission in Django REST framework

I am currently working with a model, model form and view structured in the following way: @api_view(['POST']) def addCigar(request): print(request.POST) form = CigarForm() if request.POST: form = CigarForm(request.POST) ...

Using TypeScript: Union Types for Enum Key Values

Here's the code in the TS playground too, click here. Get the Enum key values as union types (for function parameter) I have managed to achieve this with the animals object by using key in to extract the key as the enum ANIMALS value. However, I am s ...