angular 5 material - form fields stuck at 180px

后端 未结 6 1233
感动是毒
感动是毒 2020-12-29 01:26

Ive create a form in a dialog using material forms but I cant seem to get the inputs to be wider than 180px despite following numerous examples including https://material.an

6条回答
  •  别那么骄傲
    2020-12-29 01:37

    Seems like it's something to do with View Encapsulation. This thread explains it: https://github.com/angular/material2/issues/4034 but changing encapsulation for the component causes all sorts of compile failures.

    This article gave me the correct solution:https://material.angular.io/guide/customizing-component-styles

    I'll move my style to global scope...

    .formFieldWidth480 .mat-form-field-infix {
       width: 480px;
    }
    

    and in the component that opens the dialog:

    this.newDialog = this.dialog.open(NewDialogComponent,
      {
        width: '650px', height: '550px',
        data : newThing,
        panelClass : "formFieldWidth480"
      });
    

    I hope this saves someone else the day I lost...

提交回复
热议问题