Skip to content

bug(mat-radio-group): ngModel property not recognized #31906

@Gouvernathor

Description

@Gouvernathor

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

The ngModel property is not recognized on mat-radio-group, despite being documented in examples, making it impossible to read the selected radio value in a form.

Reproduction

I can't reproduce the problem on stackblitz.

    <mat-form-field>
        <mat-label>
            Position&nbsp;:
        </mat-label>
        <mat-radio-group [(ngModel)]="choisi.position">
            <mat-radio-button value="AVANT">Avant</mat-radio-button>
            <mat-radio-button value="A">À</mat-radio-button>
            <mat-radio-button value="APRES">Après</mat-radio-button>
        </mat-radio-group>
    </mat-form-field>

Expected Behavior

What happens here

Actual Behavior

The syntax highlighter says the ngModel property doesn't exist on mat-radio-group :

Can't bind to 'ngModel' since it isn't a known property of 'mat-radio-group'.
1. If 'mat-radio-group' is an Angular component and it has 'ngModel' input, then verify that it is included in the '@Component.imports' of this component.
2. If 'mat-radio-group' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@Component.schemas' of this component.ngtsc(-998002)
formulaire-amendement.component.ts(30, 18): Error occurs in the template of component FormulaireAmendementComponent.

The compilation phase triggered by ng serve fails with the same error :

X [ERROR] NG8002: Can't bind to 'ngModel' since it isn't a known property of 'mat-radio-group'.
1. If 'mat-radio-group' is an Angular component and it has 'ngModel' input, then verify that it is included in the '@Component.imports' of this component.
2. If 'mat-radio-group' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@Component.schemas' of this component. [plugin angular-compiler]

Environment

  • Angular: 19.1.0
  • CDK/Material: 19.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions