Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to disable options from mat-select based on option selected?

I was working on a project involving mat-select. I have two mat-selects,there I want to do two things:

  1. When I select ‘all’ option in either of the mat-selects all the other options should get disabled.
  2. When I select an option in one mat-select,that option needs to get disabled in the other mat-select
    This is the stackblitz link of the project

Thanks in advance, for the help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use this in you second optiongroup

<mat-optgroup *ngFor="let group of testList" [label]="group.displayName">
  <mat-option *ngFor="let num of group.pokemon; let i = index"
  [value]="num"
  disabled="{{ include.includes(num) || include.includes('all') }}"
  >
    {{ num }}
  </mat-option>
</mat-optgroup>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading