Reputation: 111
I have multiple dynamic mat-checkbox and i want to implement validation "at least one of them is selected". Here is the html code:
<div class="form-check" *ngFor="let data of pointsDepart; let i=index" [ngClass]="i == 1 ? 'marginTop': ''">
<mat-checkbox color="primary" formControlName="pointDepart" ngDefaultControl>{{data}}</mat-checkbox>
</div>
How can I implement my validator, please ? thank you
Upvotes: 2
Views: 3304
Reputation: 111
Thank you, so you recommend to not use angular material's <mat-checkbox>
and use <input type="checkbox">
instead ?
Upvotes: -1
Reputation: 19
You can try the below link for the validation of check boxs and email id https://stackblitz.com/edit/angular-at-least-one-checkbox-checked
Upvotes: 1