2

I want a material input field and a material select in one line(inside one form field). To get it done I wrote the below code but it goes into two rows. How can I get this input and drop-down in one line?.

Expected result: Frontend view

My html code :

<div fxLayout="column" class="mat-elevation-z8">
    <mat-form-field class="p-1">
        <input matInput placeholder="Search table..."
            (keyup)="updateFilter($event)">
            <mat-select name="ampm" [(ngModel)]="selectedtablesearch" (selectionChange)="updateFilter($event)">
                    <mat-option *ngFor="let draft_tblselect of draft_tblselects"
                    [value]="draft_tblselect.viewValue">{{draft_tblselect.viewValue}}</mat-option>
               </mat-select>
    </mat-form-field>
</div>
1

1 Answer 1

1

I've sorted this issue.

Code:

<div fxLayout="row" class="mat-elevation-z8"> 
    <div fxFlex="80" class="p-2">
        <mat-form-field class="w-100"> 
            <input matInput placeholder="Search table..." (keyup)="updateFilter($event)">  
        </mat-form-field>
    </div>
    <div fxFlex="20" class="p-2"> 
        <mat-form-field class="w-100"> 
            <mat-select [(ngModel)]="selectedtablesearch" (selectionChange)="updateFilter($event)"> 
                <mat-option *ngFor="let draft_tblselect of draft_tblselects" 
                    [value]="draft_tblselect.viewValue">{{draft_tblselect.viewValue}}</mat-option>  
            </mat-select>
        </mat-form-field> 
    </div>  
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

Good to see that you got it... Happy coding
Hi @denuwanchamara, Did you try adding any bg color for the dropdown field. I have the similar requirement, but when I apply color, the color is appearing as overflowing/spilling beyond the dropdown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.