html - 如何启用禁用的文本框 onclick 使用角度的按钮
问题描述
我有一个使用简单的禁用 html 标记禁用的文本框。单击启用按钮时需要启用它,单击禁用按钮时需要再次禁用它。这是下面的代码 -
app.component.html
<input type="text" disabled value="Sample text box">
<button (click)="enable()" type="button">Enable</button>
<button (click)="disable()" type="button">Disable</button>
app.component.ts
enable(){
}
disable(){
}
解决方案
您可能不需要 TypeScript,您可以从模板中引用输入
<input #input type="text" disabled value="Sample text box">
<button (click)="input.disabled = false" type="button">Enable</button>
<button (click)="input.disabled = true" type="button">Disable</button>
推荐阅读
- python - python.data.ops.dataset_ops.BatchDataset - 如何使用它来创建训练和测试数据集
- git - 如何合并 yaml 文件与两个分支上的冲突更改
- javascript - 如何在node.js中用反斜杠后跟斜杠替换斜杠?
- reactjs - 基于 Material UI 和 React 的自定义组件
- php - PHP Xampp 无法发送邮件
- facebook - Flutter facebook登录令牌为空
- php - ChartJS 堆叠条形图未显示为堆叠
- python - 来自 pandas 数据框列中字典的正则表达式匹配
- javascript - 如何用 puppeteer 填充数组?
- reactjs - 反应,在功能组件中调度后获取更新状态