8

Below code was running fine before I upgraded to 6. Not sure what changed in between! I have required modules imported as well

MatInputModule,
MatSelectModule,
MatFormFieldModule

  <mat-input-container>
    <mat-select placeholder="Sort By" formControlName="sortBy">
      <mat-option *ngFor="let sortByObject of sortByList" [value]="sortByObject.value">
        {{ sortByObject.label }}
      </mat-option>
    </mat-select>
  </mat-input-container>

2 Answers 正确答案

17

This CSS class has been removed beginning version

6.0.0-beta.5 (2018-03-23)

mat-input-container has been deprecated, instead use mat-form-field

For details of breaking changes in 6.0.0-beta.5:

https://github.com/angular/material2/blob/master/CHANGELOG.md#600-beta5-2018-03-23

For details of breaking changes in general, refer:

https://github.com/angular/material2/blob/master/CHANGELOG.md

4

As per https://material.angular.io/components/form-field/overview we are now supposed to use mat-form-field

  <mat-form-field>
    <mat-select placeholder="Select">
      <mat-option value="option">Option</mat-option>
    </mat-select>
  </mat-form-field>


来自  https://stackoverflow.com/questions/50440125/after-upgrade-to-angular-6-material-6-why-am-i-facing-mat-input-container-is-no