I am very new to Angular-material so this question might sound a bit silly, but please bear with me.
I have two checkboxes as following.
<mat-checkbox>Apply for Job</mat-checkbox>
<mat-checkbox>Modify a Job</mat-checkbox>
Let's say a user checked the first checkbox ("Apply for a Job") then later on clicks on "Modify Job" checkbox, I want the application to automatically uncheck the first one. How can I achieve this without using radio-buttons?
You can put a condition on checked attribute, as in this example:
Typescript:
selected=-1;
HTML
<div *ngFor="let item of [1,2,3]; let i = index">
<mat-checkbox [checked]="selected === i" (change)="selected = i">Check me!</mat-checkbox>
</div>
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With