角垫选择和垫选项未显示

时间:2020-12-22 21:15:18

标签: angular typescript angular-material

我的 mat-option 内容没有显示在 ui 中,我确实将 MatSelectModule 、 MatOptionModule 和 MatFormFieldModule 导入到 Module.ts 文件中。以前有人遇到过这个问题吗? 这是 Angular 文档的示例:https://material.angular.io/components/select/overview html文件:

<mat-form-field appearance="fill">
  <mat-label i18n="Select label">Select an option</mat-label>
  <mat-select>
    <mat-option *ngFor="let food of foods" [value]="food.value" > {{food.value}}
    </mat-option>
  </mat-select>
</mat-form-field>

ts 文件:

interface Food {
  value: string;
  viewValue: string;
}

Component ...


  foods: Food[] = [
    {value: 'steak-0', viewValue: 'Steak'},
    {value: 'pizza-1', viewValue: 'Pizza'},
    {value: 'tacos-2', viewValue: 'Tacos'}
  ];
  constructor(){...}

This is UI result

0 个答案:

没有答案