user9430427
user9430427

Reputation:

Angular-Material Radio button data is not binding while i select radion button

Here im upgrading my code from bootstrap to Angular Material This is my Bootstrap code its working

 <input  type="radio" class="form-control input-sm" value="Act" (change)="onSelectionChange('Act')"  name="sectionType" #sectionType="ngModel"  id="rdb1" checked=true  ngModel required>Act

I changed as

<mat-radio-group >
    <mat-radio-button  [value]="Section" (change)="onSelectionChange('Section')"name="sectionType" #sectionType="ngModel"  ngModel>Section</mat-radio-button>
</mat-radio-group>

Why I'm not able to Bind Data?

Upvotes: 1

Views: 7467

Answers (1)

Prachi
Prachi

Reputation: 3574

Use data binding at mat-radio-group level, not at mat-radio-button:

<mat-radio-group [(ngModel)]="sectionType">
    <mat-radio-button  value="Section" (change)="onSelectionChange('Section')" name="sectionType">Section</mat-radio-button>
</mat-radio-group>

You may refer to this official guide.

Upvotes: 5

Related Questions