angular - 表单组控件:无法读取未定义的属性“值”
问题描述
我有一个表单和equiid
控件,我想检查equiid
if (this.formGroupContent.controls['equiid'].value===undefined){
console.log("undefined value");
} else {
console.log("has value");
}
但是当equiid
为空时,在控制台中接收:
Cannot read property 'value' of undefined
解决方案
或许
this.formGroupContent.controls['equiid'] === undefined
它导致你提到的结果。
这只是我的一个想法,如有错误请指正。
推荐阅读
- angularjs - AngularJS UI Bootstrap - 带有 Bootstrap 4 的下拉按钮
- python - 如何使用 plt.bar 为每个字典键绘制一个元组或值列表
- python - 语义分割 DeeplabV3+ 中的 Tensorflow OOM (Out of memory) - 评估模式
- python - 无法成功执行以下脚本
- python - 尝试循环/使其更容易在文本文件中执行许多重复替换
- python - 从嵌套的html表结构中提取数据框?
- python - Python 3 tell() 在追加+读取模式下与文件指针不同步
- java - 我的自定义视图不会加载
- sails.js - 模型属性类型:json和ref有什么区别?
- java - JPanel 部分脱离了 JFrame