如何以形式angular7检测复选框检查事件?

问题描述 投票:0回答:1

使用形式和Json我创建了一个表单。现在,我想在勾选复选框时显示一个文本框。

我尝试使用ngDoCheck()方法,但我无法显示文本。 box.this方法命中每个字段点击事件,虽然我只需要检查事件。任何人都可以帮我解决这个问题。

"createConfig": [
{
    "columnName": "chkid",
    "columnSize": 50,
    "columnType": 5,
    "discreteValues": null,
    "displayName": "",
    "filterType": "e",
    "isEnabled": 1,
    "isMultiSelect": 0,
    "isRequired": 0,
    "isVisible": 1,
    "listDataProvider": null,
    "position": 2,
    "showSuggestion": 1,
    "sizeUnit": "px",
    "useDisplayValueOnly": 1
},
{
    "columnName":"nonusaddresa",
    "displayName": "Address1/Address2/City/State/Zip/PostalCode/Country",
    "position": 2,
    "columnType": 1,
    "isSortable": 0,
    "defaultSortOrder": null,
    "columnSize": 800,
    "sizeUnit": "px",
    "isVisible": 0,
    "isEnabled": 1,
    "isRequired": 0,
    "isMultiSelect": 0,
    "showSuggestion": 1,
    "useDisplayValueOnly": 1,
    "filterType": "e",
}
]

checkbox angular7 angular-formly
1个回答
0
投票

您需要在输入上有(更改)事件以查看是否选中了复选框

 <input type="checkbox" (change)="checkMethod($event)">

在你的ts文件中

  checkMethod(event)
{
if(event.target && event.target.checked)
{
//this means input is checked
}
}
© www.soinside.com 2019 - 2024. All rights reserved.