Problem with Infragistics radio button not firing change event when value is set manually

After migrating from Angular 11 to 17, I encountered a strange issue with my application's Infragistics radio button. The change event for the radio button does not trigger manually for the first time, but it works fine when changed through the application side.

To work around this issue, I tried subscribing to the valuechanges and passing the event parameter.

HTML

<div class="d-flex align-mode">
  <label class="title pull-left marginType">Mode</label>
  <div class="d-flex flex-column">
    <label class="radio-inline" style="margin-left: 10px">
      <igx-radio name="automaticSubmission"
                 formControlName="automaticSubmission"
                 (change)="onSubmissionModeChange($event)"
                 (click)="onSubmissionModeClick($event)"
                 value="regular"
                 id="regularSubmissionMode"
                 >Regular</igx-radio>
    </label>
  </div>
  <div class="d-flex flex-column marginFifteen">
    <label class="radio-inline ml-5 pl-4">
      <span *ngIf="automaticDisable; else enableAutomatic" (click)="showDisableMessage()">
        <igx-radio [disabled]="true"></igx-radio>
      </span>
      <ng-template #enableAutomatic>
        <igx-radio name="automaticSubmission"
                   formControlName="automaticSubmission"                               
                   (change)="onSubmissionModeChange($event)"
                   (click)="onSubmissionModeClick($event)"
                   value="automatic"
                   id="automaticSubmissionMode">Automatic</igx-radio>
      </ng-template>
      
    </label>
  </div>
</div>

TypeScript

 this.submissionForm = this.fb.group({
    automaticSubmission: ''
 });
        
 ngOnInit (): void {
    this.submissionForm.controls.automaticSubmission.setValue('regular');
 }
 
 onSubmissionModeChange (event) {
    alert(event.value);
    this.clearanceSubmissionFacade.setSubmissionMode(event.owner);
 }

Answer №1

It seems that there is no form in your markup. Have you checked the console of your application? Any errors should be logged there like the following:

ERROR Error: NG01050: formControlName must be used with a parent formGroup directive.  You'll need to add a formGroup
      directive and pass it an existing FormGroup instance (you can create one in your class).

    Example:

    
  <div [formGroup]="myGroup">
    <input formControlName="firstName">
  </div>

  In your class:

  this.myGroup = new FormGroup({
      firstName: new FormControl()
  });

To resolve this issue, update your markup as follows:

    <form [formGroup]="submissionForm">
      <label class="radio-inline" style="margin-left: 10px">
        <igx-radio
          name="automaticSubmission"
          formControlName="automaticSubmission"
          value="regular"
          (change)="onSubmissionModeChange($event)"
          id="regularSubmissionMode"
          >Regular</igx-radio
        >
      </label>
  </form>

Note: After examining the code in your typescript file, it appears that the radio button is being initialized with a value. This means it will be initially checked and since it is not within a radio group, it cannot be unchecked via the UI.

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

Unable to allocate information in the subscribe method

I'm experiencing an issue with the post method. Whenever I try to retrieve data using the segmentService, I always receive an empty segmentdata object in my temporarySegment variable. Strangely enough, when I use the same approach for retrieving numbe ...

Encountering an error message stating "Buffer is not defined" while working with gray-matter

Encountering an issue when trying to utilize gray-matter in Angular 9, the error message displayed is: ReferenceError: Buffer is not defined at Object.push../node_modules/gray-matter/lib/utils.js.exports.toBuffer (utils.js:32) at push../node_modul ...

Tips for generating a fixed-length array from multiple arrays with different lengths, focusing on selecting items from each array according to their significance

In order to create a quiz, I am looking to extract 'questions' from various 'topic' arrays. These topics are selected based on the user's preference and are used to populate a question bank for a 20-question quiz. The topics rated ...

I'm facing difficulty in assigning props because of the specific nature of generics in Typescript

My goal is to create a Higher Order Component (HOC) that can control a component which relies on certain props to function properly. To elaborate: I want to build a HOC that takes a component expecting props value and onChange, and modifies it so that the ...

Unusual title attributed to saving the date in Firebase

Could anyone explain why my JSON appears like this https://i.stack.imgur.com/xzG6q.png Why does it have a strange name that starts with -M-yv... instead? I am saving my data using the http.post method, passing the URL to my database and an object to save ...

Is there a way to get this reducer function to work within a TypeScript class?

For the first advent of code challenge this year, I decided to experiment with reducers. The following code worked perfectly: export default class CalorieCounter { public static calculateMaxInventoryValue(elfInventories: number[][]): number { const s ...

Using the HTML form element to achieve two-way binding on array elements

I am working with an array of objects within a component that will be iterated in the template. app.component.ts import {Component, OnInit} from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.compone ...

You cannot access the property 'subscribe' on a void type in Angular 2

fetchNews(newsCategory : any){ this.storage.get("USER_INFO").then(result =>{ this.storage.get("sessionkey").then(tempSessionKey =>{ this.email = JSON.parse(result).email; this.newSessionKey = tempSessionKey; this.authKey =JSON.stringify("Basic ...

What is the method for defining a function within a TypeScript namespace?

Suppose there is a namespace specified in the file global.d.ts containing a function like this: declare namespace MY_NAMESPACE { function doSomething(): void } What would be the appropriate way to define and describe this function? ...

`Angular 6 and the expiration of Jwt tokens`

I am currently developing an angular application that utilizes jwt for authenticating database calls. However, I encountered a problem where, when the token expires on the server, the app starts displaying blank pages instead of the expected data. This hap ...

The Angular directive ng-if does not function properly when trying to evaluate if array[0] is equal to the string value 'Value'

In my code, I want to ensure that the icon is only visible if the value at array index 0 is equal to 'Value': HTML <ion-icon *ngIf="allFamily[0] === 'Value'" class="checkas" name="checkmark"></ion-icon> TS allFamily = [ ...

There has been an error of type TypeError, as the property 'replace' cannot be read from a null value

I encountered a TypeError message, even though my application seems to be functioning properly. "ERROR TypeError: Cannot read property 'replace' of null" I'm struggling to understand how to fix this issue. Can someone provide me ...

Unable to get md-virtual-repeat to work within md-select?

Attempting to use md-select to showcase a large amount of data is causing the browser to freeze upon opening. To address this, I tried implementing md-virtual repeat within md-select for improved performance. However, the code doesn't seem to be funct ...

Is there a method for PHP to detect changes in front-end routing (specifically with Angular)?

A scenario I am encountering involves having an angular form incorporated within a php page. The issue arises when the angular form is submitted and is supposed to navigate to a different page. In actuality, once the angular form is completed, it should u ...

Is there a way to omit type arguments in TypeScript when they are not needed?

Here is a function I am currently working with: function progress<T>(data: JsonApiQueryData<T>): number { const { links, meta } = data.getMeta(); if (!links.next) { return 1; } const url = new URL(links.next); return parseInt(url ...

Exploring Angular 6 CLI Workspaces: A Guide to Creating Libraries for Exporting Services

Introduction: In Angular CLI 6, a significant feature called workspaces was introduced. A workspace has the ability to house multiple projects within it. All configurations for the workspace and its projects are stored in an 'angular.json' fi ...

Exploring the location of unit testing within async-await in Angular applications

I have been working with Angular 9+ along with karma test runner and jasmine test framework for my unit tests. My focus is on unit testing only the app component which includes dependency injection: app.component.ts import { Component, EmbeddedViewRef } ...

Obtain an array of column values within an array of objects using Angular 12

I am working on an Angular 12 project and need to fetch all data from the artisticBehaviour column in the Users table, excluding NULL values or duplicates e.g. Actor, Actor. Below is the TypeScript function that retrieves all users from the Users table. a ...

Handling HTTP Errors in Angular Components with NGRX

I have successfully integrated the store into my angular project. I am able to handle and process the successSelector, but I am facing difficulty in capturing any data with the errorSelector when an HTTP error occurs from the backend. The error is being c ...

Encountering an Angular 13 ChunkLoadError during application deployment, despite the presence of the respective chunk

We encountered an issue with our application's upgrade from Angular 11 to 13. While running 'ng serve' on the local machine works fine, deploying it to our Azure app service causes the lazy loaded modules to fail loading. The specific error ...