I use metronic angular template for front in my application and i make radio button is required but I have problem is button radio is not required
code html:
<div class="form-group kt-form__group">
<label class="example-margin">{{ 'PARTNER.TYPE' | translate }}</label>
<mat-radio-group
name="typeNature"
required
[formControl]="cartoonControl"
>
<mat-radio-button
*ngFor="let nature of partnerNatures"
value="{{nature.id}}"
>
{{nature.label}}
</mat-radio-button>
</mat-radio-group>
</div>
code ts:
initActivityEventForm() {
this.PartnerForm = this.fb.group({
firstname: ['', Validators.compose([ Validators.required,])],
lastname: ['', Validators.compose([Validators.required,])],
organization: ['', Validators.compose([Validators.required,])],
email: ['', Validators.compose([Validators.email])],
phone1: ['', Validators.compose([Validators.required])],
phone2: ['', Validators.compose([])],
typeNature: ['', Validators.compose([Validators.required])],
nature: ['', Validators.compose([Validators.required])]
}, {}
);
}
but field is not required, I add required to mat-radio-button but also error
I know it's not a good pratice but try adding [(ngModel)]
to your mat-radio-group
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.