Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mat-select not working in mat-expansion-panel

We have to show a form inside mat-expansion-panel. There are multiple fields in the form, for few of them I am using mat-select and for another few I am using mat-input.

In expansion panel, matInput is working fine but mat-select is not showing the options for selecting a possible value.

Though mat-select is working fine when showed normally.

   <mat-expansion-panel>
        <mat-expansion-panel-header>
            Heading 1
        </mat-expansion-panel-header>
        <mat-form-field>
            <mat-select placeholder="Select">
                <mat-option value="1">option 1</mat-option>
                <mat-option value="2">option 2</mat-option>
                <mat-option value="3">option 3</mat-option>
                <mat-option value="4">option 4</mat-option>
            </mat-select>
        </mat-form-field>
    </mat-expansion-panel>

Any help is appreciated.

like image 659
Ajay Avatar asked Jan 25 '18 09:01

Ajay


People also ask

How do I open my mat expansion panel by default?

By default, the expansion panel content will be initialized even when the panel is closed. To instead defer initialization until the panel is open, the content should be provided as an ng-template: <mat-expansion-panel> <mat-expansion-panel-header>

How do I get data from Mat select?

Create Select using <mat-select> To add elements to select option, we need to use <mat-option> element. To bind value with <mat-option> , we need to use value property of it. The <mat-select> has also value property to bind selected value to keep it selected. We need to use <mat-select> inside <mat-form-field> element.

How to disable expansion panel in angular material?

Expansion panels can be disabled using the disabled attribute. A disabled expansion panel can't be toggled by the user, but can still be manipulated programmatically.


1 Answers

I solved it by adding following styles

body div.cdk-overlay-container {
  z-index: 1000000;
}

By debugging, I got to know that another panel with higher z-index was overriding the mat-select options. I provided the increase z-index value to cdk-overlay-container and it worked.

Thanks for your support.

like image 163
Ajay Avatar answered Oct 22 '22 13:10

Ajay