簡體   English   中英

如何將 Angular select 選項的 position 與字段保持一致?

[英]How to keep the position of the Angular select options with the field?

在使用ng2-google-chartsangular-material時,select 列表位於圖表下方,而控件位於圖表上方。 我如何將這些放在一起?

<mat-form-field>
  <mat-label>Continent</mat-label>
  <mat-select [(ngModel)]="continents" (change)="onSelectContinent()">
    <mat-option *ngFor="let continent of continents | keyvalue" [value]="continent.key">{{continent.value}}</mat-option>
  </mat-select>
</mat-form-field>

select 列表是 ini cdk-overlay-container html 元素,它在<app_root>元素之外呈現。

模塊導入

import {MatFormFieldModule} from '@angular/material/form-field';
import {MatSelectModule} from '@angular/material/select';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';

在此處輸入圖像描述

我錯過了一個主題

添加

https://material.angular.io/guide/theming#defining-a-custom-theme

到 styles.css 文件的頂部,如在此處輸入鏈接描述中所述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM