【问题标题】:how to make Material-UI input text field "read only" in angular 12如何在角度 12 中使 Material-UI 输入文本字段“只读”
【发布时间】:2021-10-19 02:07:45
【问题描述】:

我想将文本字段设为只读,以便文本字段不可编辑, 我正在使用 Material-UI。 我已经尝试在组件的 .ts 文件中禁用它

 this.firstFormGroup.controls['gauthan_nirmit'].disable();

但它不会将数据发送回服务器。 该控件应该是只读的,但它必须在提交完成后将数据发送回服务器

【问题讨论】:

标签: html angular typescript material-ui


【解决方案1】:

只需在组件的 .html 文件中的输入字段中添加 readonly 属性

<mat-form-field>    
<input matInput readonly number formControlName="gauthan_nirmit" placeholder="" maxlength="5" autocomplete="off" appBlockCopyPaste>
</mat-form-field>

将控件设置为只读,但在提交表单时将控件数据发送到数据

【讨论】:

    猜你喜欢
    • 2020-07-30
    • 2020-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-03
    • 2021-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多