首页 > 解决方案 > 如何将三元值传递给角度变量?

问题描述

对于下面nxsId我需要在this.nxsId为空时传递 null

public nxsId: any; // declared as any
nxsId: this.nxsId

标签: angulartypescriptangular7

解决方案


"nxsId": this.nxsId !== '' ? this.nxsId : null

上面的语句,如果this.nxsId为空,那么它将分配一个null值,否则将分配一个值this.nxsId


推荐阅读