Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why mat-select not working inside the modal ? onclick it shows options behind the Modal

i Used the ngx-bootstrap Modal. But i faced problem when i used the mat-select inside of it . The mat-select Options display behind the Modal . i already these solutions here solution and also this one

here is my code

<ng-template style="border: 0px ;z-index: 100" #editTemplate>
  <mat-form-field>
                <mat-select multiple placeholder="Multiple Cities" [(ngModel)]="currentCity" name="Paris" ariaLabel="cities[0]">
                  <mat-option *ngFor="let city of cities" [value]="city.value">
                    {{ city.viewValue }}
                  </mat-option>
                </mat-select>
              </mat-form-field>
<ng-template>
like image 317
Hassan Amjad Avatar asked Jan 20 '18 03:01

Hassan Amjad


People also ask

Can we use NgModel in mat select?

We can use NgModel to get and set values in Select option for Angular Material Select as well as native Select.


Video Answer


1 Answers

It's because of conflicting z-indexes.

Quick fix

Modify the template css/scss where the modal and mat-select are placed

  .cdk-global-overlay-wrapper, .cdk-overlay-container {
     z-index: 99999 !important;
  }
like image 160
Debojyoti Avatar answered Sep 21 '22 11:09

Debojyoti