angular - 如何将三元值传递给角度变量?
问题描述
对于下面nxsId
我需要在this.nxsId
为空时传递 null
public nxsId: any; // declared as any
nxsId: this.nxsId
解决方案
"nxsId": this.nxsId !== '' ? this.nxsId : null
上面的语句,如果this.nxsId
为空,那么它将分配一个null
值,否则将分配一个值this.nxsId
。
推荐阅读
- sql-server - 如何在 SQL Server 中拆分数组
- typescript - 在数组的过滤方法之后指定所需的类型
- ruby - 如何为 ruby gem 安装修复 Errno::ENXIO (postgresql)
- azure - 设置 Azure AD 和 Cypress 以便 SSO 登录如何工作
- html - vue 中的 d3js 作为外部脚本 [d3 未定义]
- c# - System.IO.IOException: '句柄无效。: '\\.\Con''
- python - 在 python 烧瓶网页上包含单选按钮
- excel - 如何从Excel中的字段中提取特定文本?
- javascript - 使用 Javascript 阻止元素发送到下一行
- java - 如何使android中的flexbox布局内的视图占据reemiaing空间