angularjs - 如何使用 mat-slide-toggle 禁用角度输入字段?
问题描述
如何在反应表单中使用mat-slide-toggle禁用角度 mat-form-field(input) 字段,当输入字段上的滑动切换为 true 时,应启用它,否则应禁用输入字段。
解决方案
您可以在as上使用change
方法mat-slide-toggle
<mat-slide-toggle
(change)="changeDisable()" formControlName="enableWifi">
Enable Wifi</mat-slide-toggle>
<mat-form-field class="demo-full-width">
<input [disabled]="checked" formControlName="FirstName" matInput
placeholder="First Name">
</mat-form-field>
changeDisable() {
if (this.formGroup.controls['FirstName'].disabled) {
this.formGroup.controls['FirstName'].enable() ;
} else {
this.formGroup.controls['FirstName'].disable() ;
}
}
推荐阅读
- rust - 如何调试 downcast_ref 失败?
- android - Android assembleRelease 失败并出现错误:不支持的类版本号 [53.0](最大 52.0,Java 1.8)
- components - 将 ag-grid 更新到最新版本后裁剪自定义标题组件
- ios - Fastlane 选择了错误的配置文件
- floating-point - 计算机如何根据 IEEE 754 浮点表示存储 0.000000f?
- python - 如何使用 chaquopy 在 Android Studio 中运行 python 脚本?
- reactjs - React Incremeting Counter 后面
- terraform - 如何使用 terraform 将调度程序策略附加到 Gcloud 中的持久卷声明
- python - 获取所有可能的列表组合并将其保存在内存中
- serverless-framework - 如何为自定义 lambda 授权器配置无服务器框架 HttpApi Authorizer