I am trying to control the position of angular material 2 autocomplete options panel and place this panel in a separate div from the div of the actual input.
Here is what I have tried:
<div fxLayout="row">
  <div fxFlex="50">
    <form [formGroup]="formStatus.form">
      <div>
        <md-input-container>
          <input mdInput formControlName="title" placeholder="Titre">
        </md-input-container>
      </div>
      <div>
        <md-input-container>
          <input mdInput placeholder="Address" [mdAutocomplete]="auto" formControlName="address">
        </md-input-container>
      </div>
    </form>
  </div>
  <div fxFlex="50" style="background-color: palegreen">
    <!-- options panel should appear here in the palegreen div -->
    <md-autocomplete #auto="mdAutocomplete" [displayWith]="addressFormatter">
      <md-option *ngFor="let address of addresses | async" [value]="address">
        {{ address.description }}
      </md-option>
    </md-autocomplete>
  </div>
</div>
However, the options panel still appears right below the input and its position seems to be bound to that of the input...
You can control the position of angular material 2 autocomplete options panel with the following code
::ng-deep .mat-autocomplete-panel{
  position: fixed !important;
  top:30% !important;
  left: 40%;
  right: 30%;
  border: 3px solid #73AD21;
  background-color: palegreen !important;
} 
I am not sure if this exactly meets your requirements but you can control the position of mat-calendar and mat-autocomplete-panel by manipulating their parent classes. These overwritten classes need to sit level above the targeted component to take effect.
Example:
.mat-autocomplete-panel {
   position: fixed !important;
   top:30% !important;
   left: 40%;
   right: 30%;
   border: 3px solid #73AD21;
   background-color: palegreen !important;
}
Datepicker demo
Autocomplete 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